chanmap

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

Channel represents a channel that can only be closed once

func (*Channel) Close

func (c *Channel) Close()

Close closes the channel only once, so it's safe to call concurrently.

type ChannelMap

type ChannelMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ChannelMap manages a mapping of Channels. It's meant to help trigger an action across a group of listeners, without needing to handle details of group membership itself.

func NewChannelMap

func NewChannelMap() *ChannelMap

NewChannelMap returns a ChannelMap instance

func (*ChannelMap) Add

func (cm *ChannelMap) Add(key string) chan struct{}

Add returns the control channel for a given key, creating it if necessary

func (*ChannelMap) Close

func (cm *ChannelMap) Close(key string)

Close closes a matching control channel and discards it

func (*ChannelMap) CloseAll

func (cm *ChannelMap) CloseAll()

CloseAll closes all control channels

func (*ChannelMap) Get

func (cm *ChannelMap) Get(key string) (chan struct{}, bool)

Get returns the control channel for a given key

Jump to

Keyboard shortcuts

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