Help us shape the future of Go! Take the 2026 Go Developer Survey

chanmap

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	*sync.Mutex

	// ChildrenByParent holds a map of child channels
	ChildrenByParent map[string]map[string]chan struct{}
	// ParentByChild helps us delete efficiently, by telling us which parent map the child is in
	ParentByChild map[string]string
}

func New

func New() *Store

func (*Store) Add

func (s *Store) Add(parent, child string, ch chan struct{}) error

parent is typically a bookingID, child for clientname

func (*Store) DeleteAndCloseChild

func (s *Store) DeleteAndCloseChild(child string) error

DeleteAndClose closes the child's channel and deletes it this approach ensures the channel cannot be closed twice

func (*Store) DeleteAndCloseParent

func (s *Store) DeleteAndCloseParent(parent string) error

DeleteParent deletes the parent, and all its children, closing the children's channels

func (*Store) DeleteChild

func (s *Store) DeleteChild(child string) error

Delete deletes the child, without closing the channel

func (*Store) DeleteParent

func (s *Store) DeleteParent(parent string) error

DeleteParent deletes the parent, and all its children, without closing the children's channels

Jump to

Keyboard shortcuts

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