luci: go.chromium.org/luci/common/sync/cancelcond Index | Files

package cancelcond

import "go.chromium.org/luci/common/sync/cancelcond"

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

Index

Package Files

cancelCond.go

type Cond Uses

type Cond struct {
    *sync.Cond
}

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 2018-10-19. Refresh now. Tools for package owners.