promise

package
v0.28.15 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 1 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{}, doneCh <-chan struct{}, 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 `doneCh` 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