Documentation
¶
Overview ¶
Package yieldpoint provides cooperative goroutine yielding based on priority-aware scheduling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Cond = sync.NewCond(&Mu)
Cond is the condition variable used for efficient blocking
var DefaultYieldDuration = 1 * time.Millisecond
DefaultYieldDuration is the default duration to sleep when yielding
var HighPriorityCount atomic.Int32
HighPriorityCount tracks the number of active high-priority sections
var Mu sync.Mutex
Mu is the mutex used for efficient blocking in WaitIfActive
var SpinWaitIterations = 1000
SpinWaitIterations is the number of iterations to spin-wait before falling back to mutex-based waiting
Functions ¶
func EnterHighPriority ¶
func EnterHighPriority()
EnterHighPriority begins a high-priority section. Multiple calls are supported through reference counting.
func ExitHighPriority ¶
func ExitHighPriority()
ExitHighPriority ends a high-priority section. If this is the last high-priority section, it will signal any waiting goroutines.
func IsHighPriorityActive ¶
func IsHighPriorityActive() bool
IsHighPriorityActive returns true if any high-priority sections are currently active.
func MaybeYield ¶
func MaybeYield()
MaybeYield voluntarily yields the current goroutine if any high-priority sections are active.
func MaybeYieldWithContext ¶
MaybeYieldWithContext is a context-aware version of MaybeYield
func SetSpinWaitIterations ¶
func SetSpinWaitIterations(n int)
SetSpinWaitIterations sets the number of iterations to spin-wait before falling back to mutex-based waiting
func WaitIfActive ¶
func WaitIfActive()
WaitIfActive blocks the current goroutine until no high-priority sections are active. This is an efficient blocking operation that uses sync.Cond to avoid busy waiting.
func WaitIfActiveFast ¶
func WaitIfActiveFast()
WaitIfActiveFast is a high-performance version of WaitIfActive that uses a spin-wait strategy before falling back to mutex-based waiting. This is suitable for performance-critical code paths where the wait time is expected to be very short.
func WaitIfActiveWithContext ¶
WaitIfActiveWithContext is a context-aware version of WaitIfActive
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic_usage
command
|
|
|
context_support
command
|
|
|
fast_support
command
|
|
|
nested_priority
command
|
|
|
wait_if_active
command
|