sync

package
v0.0.0-...-d809d1c Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster[T any] struct {
	// contains filtered or unexported fields
}

Broadcaster reads from one chan and writes to many subscribed chans, Subscribe will return a token, and a receive-only chan for reads, Unsubscribe must be called with the token to close the subscription, if not called, the system will not shut down gracefully Broadcast must be called in a separate long-running goroutine, this will not return even if there are no subscribers to relay msgs to, Broadcast will only return once shutdown is initiated

func NewBroadcaster

func NewBroadcaster[T any]() *Broadcaster[T]

func (*Broadcaster[T]) Broadcast

func (b *Broadcaster[T]) Broadcast(shtdwnCtx context.Context)

func (*Broadcaster[T]) Get

func (b *Broadcaster[T]) Get() T

func (*Broadcaster[T]) Subscribe

func (b *Broadcaster[T]) Subscribe() (int, <-chan T)

func (*Broadcaster[T]) Unsubscribe

func (b *Broadcaster[T]) Unsubscribe(token int)

func (*Broadcaster[T]) Write

func (b *Broadcaster[T]) Write(v T)

Jump to

Keyboard shortcuts

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