Documentation
¶
Overview ¶
Package msync defines some helpful types for managing concurrency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handoff ¶
type Handoff[T any] struct { // contains filtered or unexported fields }
Handoff is a singly-buffered level-triggered producer-consumer handoff. A consumer blocks on the Ready channel until a producer calls Send. Calls to Send do not block; once a value has been sent to the handoff, subsequent values are discarded until the first one was consumed.
type Trigger ¶
type Trigger struct {
// contains filtered or unexported fields
}
Trigger is an edge-triggered condition shared by multiple waiting goroutines. It is analogous in effect to the standard condition variable (sync.Cond) type, but uses a channel for signaling so that the waiters can select on its completion.
A zero value is ready for use but must not be copied after first use.
type Value ¶ added in v0.0.2
type Value[T any] struct { // contains filtered or unexported fields }
Value holds a single value of type T that can be concurrently accessed by multiple goroutines. A zero Value is ready for use, but must not be copied after its first use.
func (*Value[T]) Get ¶ added in v0.0.2
func (v *Value[T]) Get() T
Get returns the current value stored in v.
func (*Value[T]) Set ¶ added in v0.0.2
func (v *Value[T]) Set(newValue T)
Set updates the value stored in v to newValue.
func (*Value[T]) Wait ¶ added in v0.0.2
Wait blocks until v.Set is called, or until ctx ends, and returns the current value in v. The flag indicating whether Set was called (true) or ctx timed out (false).
If v.Set is not called before ctx ends, Wait returns the value v held when Wait was called. Otherwise, Wait returns the value from one of the v.Set calls made during its execution. If multiple goroutines set v concurrently, Wait will return the value from one of them, but not necessarily the first.