lib/celluloid/evented_mailbox.rb in celluloid-0.14.1 vs lib/celluloid/evented_mailbox.rb in celluloid-0.15.0.pre

- old
+ new

@@ -11,30 +11,27 @@ # Add a message to the Mailbox def <<(message) @mutex.lock begin - if mailbox_full - Logger.debug "Discarded message: #{message}" + if mailbox_full || @dead + dead_letter(message) return end if message.is_a?(SystemEvent) - # Silently swallow system events sent to dead actors - return if @dead - # 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[:celluloid_actor] @reactor.wakeup unless current_actor && current_actor.mailbox == self rescue IOError - raise MailboxError, "dead recipient" + Logger.crash "reactor crashed", $! + dead_letter(message) ensure @mutex.unlock rescue nil end nil end @@ -57,11 +54,10 @@ message = next_message(block) end message rescue IOError - shutdown # force shutdown of the mailbox raise MailboxShutdown, "mailbox shutdown called during receive" end # Obtain the next message from the mailbox that matches the given block def next_message(block) @@ -73,10 +69,11 @@ end end # Cleanup any IO objects this Mailbox may be using def shutdown - @reactor.shutdown - super + super do + @reactor.shutdown + end end end end