cancelcond

package
v0.0.0-...-678bb0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cond

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

func New(l sync.Locker) *Cond

New creates a new Context-cancellable Cond.

func (*Cond) Wait

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL