promise

package
Version: v0.16.1-beta Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Promise

type Promise interface {
	// Returns whether this promise is complete yet, without blocking.
	IsComplete() bool

	// Returns whether this promise completed with errors, without blocking.
	IsError() bool

	// Unblock all goroutines awaiting promise completion.
	Complete(errors []error)

	// Blocks the caller until the promise is marked complete. This function
	// is equivalent to invoking AwaitUntil() with a zero-length duration.
	// To avoid blocking the caller indefinitely, use AwaitUntil() with a
	// non-zero duration instead.
	Await() []error

	// Blocks the caller until the promise is marked complete, or the supplied
	// duration has elapsed. If the promise has not been completed before the
	// await times out, this function returns with nonempty errors. If the
	// supplied duration has zero length, this await will never time out.
	AwaitUntil(timeout time.Duration) []error

	// Invokes the supplied function after this promise completes. This function
	// is equivalent to invoking AndThenUntil() with a zero-length duration.
	// To avoid blocking a goroutine indefinitely, use AndThenUntil() with a
	// non-zero duration instead.
	AndThen(f func([]error))

	// Invokes the supplied function after this promise completes or times out
	// after the supplied duration. If the supplied duration has zero length,
	// the deferred execution will never time out.
	AndThenUntil(timeout time.Duration, f func([]error))
}

A disposable write-once latch, to act as a synchronization barrier to signal completion of some asynchronous operation (successful or otherwise).

Functions that operate on this type (IsComplete, Complete, Await, AwaitUntil) are idempotent and thread-safe.

func NewPromise

func NewPromise() Promise

type RendezVous

type RendezVous interface {
	// Returns whether this rendez-vous is complete yet, without blocking.
	IsComplete() bool

	// Complete process A's half of the rendez-vous, and block until process
	// B has done the same.
	A()

	// Complete process B's half of the rendez-vous, and block until process
	// A has done the same.
	B()
}

A reciprocal promise that makes it easy for two coordinating routines A and B to wait on each other before proceeding.

func NewRendezVous

func NewRendezVous() RendezVous

Source Files

Jump to

Keyboard shortcuts

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