Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remedy send reentrancy

  • Loading branch information...
commit ff989faf620c9b6f5dd55b6f0ce471d02d145d7c 1 parent 8cc98de
@mental authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/Actor.coffee
View
11 src/Actor.coffee
@@ -44,6 +44,7 @@ class LocalActor
constructor: (@actor_id) ->
@mailbox = []
@killed = false
+ @running = false
@state = {}
@receivers = []
@kill_handler = null
@@ -55,7 +56,7 @@ class LocalActor
unlink: (actor_id) ->
delete @linked[actor_id]
- _consume_message: (message) ->
+ consume_message: (message) ->
for receiver in @receivers
cont = receiver(message)
if cont
@@ -65,8 +66,8 @@ class LocalActor
return false
send: (message) ->
- unless @_consume_message(message)
- @mailbox.push(message)
+ return if not @running and @consume_message(message)
+ @mailbox.push(message)
kill: (killer_id, reason) ->
if @kill_handler
@@ -115,6 +116,7 @@ class LocalActor
return if actor.killed
reason = null
current_actor = actor
+ actor.running = true
try
cont.call(actor.state)
catch e
@@ -123,10 +125,11 @@ class LocalActor
reason = e
finally
current_actor = NULL_ACTOR
+ actor.running = false
unless actor.killed
if actor.receivers.length > 0
for index in [0...actor.mailbox.length]
- if actor._consume_message(actor.mailbox[index])
+ if actor.consume_message(actor.mailbox[index])
actor.mailbox.splice(index, 1)
else
actor.shutdown(reason)

0 comments on commit ff989fa

Please sign in to comment.
Something went wrong with that request. Please try again.