lib/celluloid.rb in celluloid-0.11.0 vs lib/celluloid.rb in celluloid-0.11.1
- old
+ new
@@ -1,8 +1,9 @@
require 'logger'
require 'thread'
require 'timeout'
+require 'set'
module Celluloid
SHUTDOWN_TIMEOUT = 120 # How long actors have to terminate
@logger = Logger.new STDERR
@@ -167,10 +168,17 @@
else
@mailbox_factory = proc { klass.new }
end
end
+ # Mark methods as running exclusively
+ def exclusive(*methods)
+ @exclusive_methods ||= Set.new
+ @exclusive_methods.merge methods.map(&:to_sym)
+ end
+ attr_reader :exclusive_methods
+
# Create a mailbox for this actor
def mailbox_factory
if defined?(@mailbox_factory)
@mailbox_factory.call
elsif defined?(super)
@@ -295,10 +303,15 @@
# actor, not only current message processing.
def exclusive(&block)
Thread.current[:actor].exclusive(&block)
end
+ # Are we currently exclusive
+ def exclusive?
+ Celluloid.exclusive?
+ end
+
# Call a block after a given interval, returning a Celluloid::Timer object
def after(interval, &block)
Thread.current[:actor].after(interval, &block)
end
@@ -331,11 +344,11 @@
# bang methods are async calls
if meth.to_s.match(/!$/)
unbanged_meth = meth.to_s.sub(/!$/, '')
args.unshift unbanged_meth
- call = AsyncCall.new(nil, :__send__, args, block)
+ call = AsyncCall.new(:__send__, args, block)
begin
Thread.current[:actor].mailbox << call
rescue MailboxError
# Silently swallow asynchronous calls to dead actors. There's no way
# to reliably generate DeadActorErrors for async calls, so users of
@@ -366,13 +379,13 @@
require 'celluloid/registry'
require 'celluloid/responses'
require 'celluloid/signals'
require 'celluloid/task'
require 'celluloid/thread_handle'
-require 'celluloid/timers'
require 'celluloid/uuid'
require 'celluloid/actor'
require 'celluloid/future'
require 'celluloid/pool_manager'
require 'celluloid/supervision_group'
require 'celluloid/supervisor'
+require 'celluloid/notifications'