diff --git a/actor/inbox.go b/actor/inbox.go index 075de83..27af0f3 100644 --- a/actor/inbox.go +++ b/actor/inbox.go @@ -13,10 +13,11 @@ const ( ) const ( - stopped int32 = iota + new int32 = iota starting idle running + stopped ) type Scheduler interface { @@ -55,7 +56,7 @@ func NewInbox(size int) *Inbox { return &Inbox{ rb: ringbuffer.New[Envelope](int64(size)), scheduler: NewScheduler(defaultThroughput), - procStatus: stopped, + procStatus: new, } } @@ -96,7 +97,7 @@ func (in *Inbox) run() { func (in *Inbox) Start(proc Processer) { // transition to "starting" and then "idle" to ensure no race condition on in.proc - if atomic.CompareAndSwapInt32(&in.procStatus, stopped, starting) { + if atomic.CompareAndSwapInt32(&in.procStatus, new, starting) { in.proc = proc atomic.SwapInt32(&in.procStatus, idle) in.schedule()