qu

package
v1.2.18 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Unlicense Imports: 8 Imported by: 0

README

qu

observable signal channels

simple channels that act as breakers or momentary one-shot triggers.

can enable logging to get detailed information on channel state, and channels do not panic if closed channels are attempted to be closed or signalled with.

provides a neat function based syntax for usage.

wait function does require use of the <- receive operator prefix to be used in a select statement.

usage

creating channels:
unbuffered
newSigChan := qu.T()
buffered
newBufferedSigChan := qu.Ts(5)
closing
newSigChan.Q()
signalling
newBufferedSigChan.Signal()
logging features
numberOpenUnbufferedChannels := GetOpenUnbufferedChanCount()

numberOpenBufferedChannels := GetOpenBufferedChanCount()

print a list of closed and open channels known by qu:

PrintChanState() 

garbage collection

this library automatically cleans up closed channels once a minute to free resources that have become unused.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOpenBufferedChanCount

func GetOpenBufferedChanCount() (o int)

GetOpenBufferedChanCount returns the number of qu channels that are still open

func GetOpenUnbufferedChanCount

func GetOpenUnbufferedChanCount() (o int)

GetOpenUnbufferedChanCount returns the number of qu channels that are still open

func PrintChanState

func PrintChanState()

PrintChanState creates an output showing the current state of the channels being monitored This is a function for use by the programmer while debugging

func SetLogging

func SetLogging(on bool)

SetLogging switches on and off the channel logging

Types

type B

type B = []byte

type C

type C chan struct{}

C is your basic empty struct signalling channel

func T

func T() C

T creates an unbuffered chan struct{} for trigger and quit signalling (momentary and breaker switches)

func Ts

func Ts(n int) C

Ts creates a buffered chan struct{} which is specifically intended for signalling without blocking, generally one is the size of buffer to be used, though there might be conceivable cases where the channel should accept more signals without blocking the caller

func (C) IsClosed

func (c C) IsClosed() bool

IsClosed exposes a test to see if the channel is closed

func (C) Q

func (c C) Q()

Q closes the channel, which makes it emit a nil every time it is selected.

func (C) Signal

func (c C) Signal()

Signal sends struct{}{} on the channel which functions as a momentary switch, useful in pairs for stop/start

func (C) Wait

func (c C) Wait() <-chan struct{}

Wait should be placed with a `<-` in a select case in addition to the channel variable name

type Ctx

type Ctx = context.T

type E

type E = error

type N

type N = int

type S

type S = string

Jump to

Keyboard shortcuts

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