lib/celluloid/evented_mailbox.rb in celluloid-0.16.0.pre2 vs lib/celluloid/evented_mailbox.rb in celluloid-0.16.0.pre3
- old
+ new
@@ -35,20 +35,21 @@
end
nil
end
# Receive a message from the Mailbox
- def receive(timeout = nil, &block)
+ def check(timeout = nil, &block)
# Get a message if it is available and process it immediately if possible:
if message = next_message(block)
return message
end
- # ... otherwise, run the reactor once, either blocking or will return after the given timeout.
+ # ... otherwise, run the reactor once, either blocking or will return
+ # after the given timeout:
@reactor.run_once(timeout)
- # This is a hack to get the main Actor#run loop to recompute the timeout:
- raise TimeoutError
+ # No message was received:
+ return nil
rescue IOError
raise MailboxShutdown, "mailbox shutdown called during receive"
end
# Obtain the next message from the mailbox that matches the given block