promise

package
v0.29.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WriteOnce added in v0.18.0

type WriteOnce interface {
	// Get reads the current value of this variable.  If this
	// variable is not set yet then this call blocks until this
	// variable gets a value.
	Get() interface{}

	// Set normally writes a value into this variable, unblocks every
	// goroutine waiting for this variable to have a value, and
	// returns true.  In the unhappy case that this variable is
	// already set, this method returns false without modifying the
	// variable's value.
	Set(interface{}) bool
}

WriteOnce represents a variable that is initially not set and can be set once and is readable. This is the common meaning for "promise".

func NewWriteOnce added in v0.23.0

func NewWriteOnce(initial interface{}, doneCtx context.Context, doneVal interface{}) WriteOnce

NewWriteOnce makes a new thread-safe WriteOnce.

If `initial` is non-nil then that value is Set at creation time.

If a `Get` is waiting soon after the channel associated with the `doneCtx` becomes selectable (which never happens for the nil channel) then `Set(doneVal)` effectively happens at that time.

Jump to

Keyboard shortcuts

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