Skip to content

Commit 45d8d5c

Browse files
committed
chore(mailbox): add comment and cosmetics
1 parent a83f650 commit 45d8d5c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

actor/mailbox.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ func (w *mailboxWorker[T]) DoWork(ctx Context) WorkerStatus {
297297
}
298298

299299
func (w *mailboxWorker[T]) OnStop() {
300+
// close receiveC, after receiving all data,
301+
// so everyone reading from this mailbox can be
302+
// notified that no more messages will ever be received.
303+
defer close(w.receiveC)
304+
300305
// receiveC channel needs to receive all data before closing
301306
if w.options.StopAfterReceivingAll {
302307
// first: receive data from queue
@@ -315,6 +320,4 @@ func (w *mailboxWorker[T]) OnStop() {
315320
}
316321
}
317322
}
318-
319-
close(w.receiveC)
320323
}

0 commit comments

Comments
 (0)