Documentation
¶
Index ¶
- Variables
- func Fork(ctx context.Context) context.Context
- func NonBlocking(ctx context.Context) bool
- func WithBlocking(ctx context.Context) context.Context
- func WithNonBlocking(ctx context.Context) context.Context
- func WithStore(ctx context.Context, s *Store) context.Context
- type Item
- type Store
- type Token
- type Var
- type Variable
Constants ¶
This section is empty.
Variables ¶
var ( // Error of a Reset with a token that already undid its Set ErrTokenUsed = errors.New("token already used") // Error of a Reset with a token another variable's Set gave ErrTokenVariable = errors.New("token belongs to another variable") // Error of a Reset through a context running in another store than the Set did ErrTokenStore = errors.New("token belongs to another store") )
Functions ¶
func Fork ¶
Context running in a copy of the store ctx runs in, so sets on either side stay apart from then on
func NonBlocking ¶
Whether ctx carries the non-blocking mark WithNonBlocking sets and WithBlocking lifts
func WithBlocking ¶
Context with the non-blocking mark lifted, as a worker goroutine started off a marked context runs: blocking waits are fine there
func WithNonBlocking ¶
Context marked as serving asynchronous dispatch, where callees must not park the goroutine on blocking waits; NonBlocking reports the mark
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Mutable set of variable values a context carries: a Set made through the context is seen by all later code running in it, and Copy forks it so later sets on either side stay apart
func (*Store) Checkpoint ¶
func (s *Store) Checkpoint() (restore func())
Restore point: calling the returned func puts every value of s back to what it holds now
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Record of one Set that Reset uses to put the earlier value back once
type Var ¶
type Var[T any] struct { // contains filtered or unexported fields }
Variable whose value lives in the Store of the context it is used through, reading as its default where that Store holds none