Documentation
¶
Index ¶
Constants ¶
View Source
const ( StatusNew = iota StatusRun StatusStop )
status from StatusNew to StatusStopped, no loop.
Variables ¶
View Source
var ErrLineIsFull = errors.New("too many tasks, add a worker please")
ErrLineIsFull conveyor is full, can not puts any part. Client judges whether to add more workers according to the CPU's load.
View Source
var ErrLineStopped = errors.New("the conveyor is stopped")
View Source
var ErrUnallowed = errors.New("the factory is not allowed to add new conveyor")
Functions ¶
This section is empty.
Types ¶
type IConveyor ¶
type IConveyor interface { // PutPart puts parts on conveyor belt, if a conveyor is full, return ErrLineIsFull. PutPart(p Part, duration time.Duration) error // GetPart return a part and the status of conveyor if closed. GetPart() (Part, bool) // Run lets the conveyor rolling. Run() // Stop stops a conveyor. Stop() }
ConveyorI receives parts, and workers take parts from it.
type IFactory ¶
type IFactory interface { // AddLine add conveyor to the factory. AddLine(name string, c IConveyor) error // Run lets all conveyors running. Run() // Stop lets all conveyors stop. Stop() // GetLine GetLine(name string) IConveyor }
func NewFactory ¶
func NewFactory() IFactory
type IWorker ¶
type IWorker interface { Working() Stop() }
Worker - worker take parts from conveyor and handle them.
type TConveyor ¶
type TConveyor struct { StopSignC chan struct{} // receive stop signal. // contains filtered or unexported fields }
type TFactory ¶
type TFactory struct {
// contains filtered or unexported fields
}
emptyFactory a instance of Factory interface
Click to show internal directories.
Click to hide internal directories.