lib/celluloid/io/mailbox.rb in celluloid-io-0.11.0 vs lib/celluloid/io/mailbox.rb in celluloid-io-0.12.0
- old
+ new
@@ -12,29 +12,25 @@
# Add a message to the Mailbox
def <<(message)
@mutex.lock
begin
- @messages << message
- current_actor = Thread.current[:actor]
- @reactor.wakeup unless current_actor && current_actor.mailbox == self
- rescue IOError
- raise MailboxError, "dead recipient"
- ensure
- @mutex.unlock rescue nil
- end
- nil
- end
+ if message.is_a?(SystemEvent)
+ # Silently swallow system events sent to dead actors
+ return if @dead
- # Add a high-priority system event to the Mailbox
- def system_event(event)
- @mutex.lock
- begin
- @messages.unshift event
+ # SystemEvents are high priority messages so they get added to the
+ # head of our message queue instead of the end
+ @messages.unshift message
+ else
+ raise MailboxError, "dead recipient" if @dead
+ @messages << message
+ end
+
current_actor = Thread.current[:actor]
@reactor.wakeup unless current_actor && current_actor.mailbox == self
rescue IOError
- # Silently fail if messages are sent to dead actors
+ raise MailboxError, "dead recipient"
ensure
@mutex.unlock rescue nil
end
nil
end