chansync

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 4 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastCond

type BroadcastCond struct {
	// contains filtered or unexported fields
}

Can be used as zero-value. Due to the caller needing to bring their own synchronization, an equivalent to "sync".Cond.Signal is not provided. BroadcastCond is intended to be selected on with other channels.

func (*BroadcastCond) Broadcast

func (me *BroadcastCond) Broadcast()

func (*BroadcastCond) Signaled

func (me *BroadcastCond) Signaled() events.Signaled

Should be called before releasing locks on resources that might trigger subsequent Broadcasts. The channel is closed when the condition changes.

type Flag

type Flag struct {
	// contains filtered or unexported fields
}

Flag wraps a boolean value that starts as false (off). You can wait for it to be on or off, and set the value as needed.

func (*Flag) Bool

func (me *Flag) Bool() bool

func (*Flag) Clear

func (me *Flag) Clear()

func (*Flag) IsSet added in v0.6.0

func (me *Flag) IsSet() bool

To match the SetOnce API.

func (*Flag) Off

func (me *Flag) Off() events.Active

func (*Flag) On

func (me *Flag) On() events.Active

func (*Flag) Set

func (me *Flag) Set()

func (*Flag) SetBool

func (me *Flag) SetBool(b bool)

type LevelTrigger

type LevelTrigger struct {
	// contains filtered or unexported fields
}

func (*LevelTrigger) Active

func (me *LevelTrigger) Active() events.Active

func (*LevelTrigger) Signal

func (me *LevelTrigger) Signal() events.Signal

type ReadOnlyFlag added in v0.5.0

type ReadOnlyFlag interface {
	Bool() bool
	On() events.Active
	Off() events.Active
}

type Semaphore

type Semaphore struct {
	// contains filtered or unexported fields
}

Channel semaphore, as is popular for controlling access to limited resources. Should not be used zero-initialized.

func NewSemaphore

func NewSemaphore(n int) Semaphore

Returns an initialized semaphore with n slots.

func (Semaphore) Acquire

func (me Semaphore) Acquire() events.Acquire

Returns a channel for acquiring a slot.

func (Semaphore) Cap added in v0.6.0

func (me Semaphore) Cap() int

Returns the resource count when all are available.

func (Semaphore) Release

func (me Semaphore) Release() events.Release

Returns a channel for releasing a slot.

func (Semaphore) Value added in v0.4.0

func (me Semaphore) Value() int

Returns the current number of acquired values.

type SetOnce

type SetOnce struct {
	// contains filtered or unexported fields
}

SetOnce is a boolean value that can only be flipped from false to true.

func (*SetOnce) Done

func (me *SetOnce) Done() events.Done

Returns a channel that is closed when the event is flagged.

func (*SetOnce) IsSet

func (me *SetOnce) IsSet() bool

func (*SetOnce) Set

func (me *SetOnce) Set() (first bool)

Set only returns true the first time it is called.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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