dishes

package
v0.0.0-...-c6e3130 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 1 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {

	// This is the message passing channel.
	//
	// The manager receive loop only reads from it (in a 'range Ch') and writes to the 'chan *string' channel values.
	//
	// The message sender must only write to Ch and then read from the channel values. Simply close this channel to terminate the receive loop.
	//
	// The manager will write a valid dish name back on the 'chan *string' if there are any left, or nil if there are none left.
	Ch chan chan *string
	// contains filtered or unexported fields
}

Manager is an actor that manages the internal list of dishes and number of morsels left in each.

func NewManager

func NewManager() *Manager

NewManager creates a new Manager actor and starts the receive loop in a background goroutine.

Example usage:

mgr := NewManager()
// get a dish that has morsels left
dishNameCh := make(chan *string)
mgr.Ch <- dishNameCh
dishName := <-dishNameCh
if dishName == nil {
  // there are no more morsels left of any dish!
} else {
  fmt.Println("got a morsel of %s!", *dishName)
}

Jump to

Keyboard shortcuts

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