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)
}
Click to show internal directories.
Click to hide internal directories.