luci: Index | Files

package cancelcond

import ""

Package cancelcond implements a wrapper around sync.Cond that response to context.Context cancellation.


Package Files


type Cond Uses

type Cond struct {

Cond is a wrapper around a sync.Cond that overloads its Wait method to accept a Context. This Context can be cancelled to prematurely terminate the Wait().

func New Uses

func New(l sync.Locker) *Cond

New creates a new Context-cancellable Cond.

func (*Cond) Wait Uses

func (cc *Cond) Wait(c context.Context) (err error)

Wait wraps sync.Cond's Wait() method. It blocks, waiting for the underlying Conn to be signalled. If the Context is cancelled prematurely, Wait() will signal the underlying Cond and unblock it.

Wait must be called while holding the Cond's lock. It yields the lock while it is blocking and reclaims it prior to returning.

Package cancelcond imports 2 packages (graph) and is imported by 2 packages. Updated 2019-08-25. Refresh now. Tools for package owners.