dynselect

package module
v0.0.0-...-dea8e15 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: MIT, Unlicense Imports: 4 Imported by: 1

README

dynselect

This package implements a highly-situational, reflection-based select statement. It allows you to construct a runtime-modifiable pool of channels that are monitored for close with a select. This is useful primarily when monitoring a pool of contexts for cancellation if you need to perform some additional cleanup after detecting the context cancellation. See the tests for some example usages.

If you don't understand why this is useful, stay away. You definitely don't need it, and it may yet prove to be a bad idea in practice.

Dual UNLICENSE/MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Select

func Select[T any](add <-chan <-chan T) (closed <-chan []<-chan T)

Select implements the dynamic supervision of a pool of channels that are expected to eventually close. You add channels to the supervised pool by sending them on the provided add channel, and channels that close while supervised are emitted on the returned closed channel.

This function spawns a new goroutine to perform the supervision. This goroutine will shut down when the provided add channel is closed and all supervised channels close. The returned closed channel will close when the goroutine exits.

Types

This section is empty.

Jump to

Keyboard shortcuts

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