Skip to content

Commit

Permalink
fix mailboxempty issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeralsing committed Apr 8, 2024
1 parent 59d175c commit f4cee9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions actor/mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ process:
}
}

for _, ms := range m.middlewares {
ms.MailboxEmpty()
if user == 0 && (atomic.LoadInt32(&m.suspended) == 0) {
for _, ms := range m.middlewares {
ms.MailboxEmpty()
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions examples/actor-mailbox-middleware/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"log/slog"
"time"

console "github.com/asynkron/goconsole"
"github.com/asynkron/protoactor-go/actor"
Expand Down Expand Up @@ -36,5 +37,7 @@ func main() {
)
pid := rootContext.Spawn(props)
rootContext.Send(pid, "Hello")
time.Sleep(1 * time.Second)
rootContext.Send(pid, "Hello")
_, _ = console.ReadLine()
}

0 comments on commit f4cee9b

Please sign in to comment.