qu

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: Unlicense, Unlicense Imports: 6 Imported by: 0

README

qu

observable signal channels

This is a wrapper around chan struct{} that forgives some common mistakes like sending on closed channels and closing cllosed channels, as well as printing logs about when channels are created, waited on, sent to and closed.

This library makes debugging concurrent code a lot easier. IMHO. YMMV.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var F, E, W, I, D, _ log.LevelPrinter = log.GetLogPrinterSet(subsystem)

Functions

func GetOpenChanCount

func GetOpenChanCount() (o int)

GetOpenChanCount returns the number of qu channels that are still open todo: this needs to only apply to unbuffered type

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 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) 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

Jump to

Keyboard shortcuts

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