Code
使用设计模式中的状态机模式实现”进程的三态模型扭转“
state.go
package state
import "fmt"
type Process struct {
state State
}
func (p *Process) Run() {
p.state.Run(p)
}
func (p *Process) Pending() {
p.state.Pending(p)
}
func (p *Process) Wait() {
p.state.Wait(p)
}
func (p *Process) TimeOut() {
p.state.TimeOut(p)
}
func NextProcess(state State) Process {
return Process{
state: state,
}
}
func (p *Proc