Documentation ¶
Overview ¶
Package ctxsync contains some synchronization primitvies that are aware of a context becoming done and can bail on waits in that case.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CancelableCond ¶
type CancelableCond struct { // L is held while observing or changing the condition L sync.Locker // contains filtered or unexported fields }
CancelableCond is like sync.Cond, but you can wait with a context and bail when the context is done.
func NewCancelableCond ¶
func NewCancelableCond(l sync.Locker) *CancelableCond
NewCancelableCond returns a new CancelableCond.
func (*CancelableCond) Broadcast ¶
func (c *CancelableCond) Broadcast()
Broadcast wakes all goroutines waiting on c. The caller must hold c.L during the call.
func (*CancelableCond) Wait ¶
func (c *CancelableCond) Wait(ctx context.Context) bool
Wait atomically unlocks c.L and suspends execution of the calling goroutine. After later resuming execution, Wait locks c.L before returning. Returns true if awoken by Broadcast or false if the context is done. Because c.L is not locked when Wait first resumes, the caller typically cannot assume that the condition is true when Wait returns. Instead, the caller should Wait in a loop.