lib/celluloid.rb in celluloid-0.12.0.pre2 vs lib/celluloid.rb in celluloid-0.12.0.pre3
- old
+ new
@@ -141,12 +141,20 @@
def mailbox_class(klass)
@mailbox_factory = proc { klass.new }
end
# Define the default task type for this class
- def task_class(klass)
- @task_class = klass
+ def task_class(klass = nil)
+ if klass
+ @task_class = klass
+ elsif defined?(@task_class)
+ @task_class
+ elsif superclass.respond_to? :task_class
+ superclass.task_class
+ else
+ Celluloid.task_class
+ end
end
# Mark methods as running exclusively
def exclusive(*methods)
if methods.empty?
@@ -172,11 +180,11 @@
def actor_options
{
:mailbox => mailbox_factory,
:exit_handler => @exit_handler,
:exclusive_methods => @exclusive_methods,
- :task_class => @task_class
+ :task_class => task_class
}
end
def ===(other)
other.kind_of? self
@@ -362,16 +370,24 @@
# Celluloid::Future, which uses a thread from InternalPool to run the block
Future.new(&block).value
end
# Handle async calls within an actor itself
- def async(meth, *args, &block)
- Actor.async Thread.current[:actor].mailbox, meth, *args, &block
+ def async(meth = nil, *args, &block)
+ if meth
+ Actor.async Thread.current[:actor].mailbox, meth, *args, &block
+ else
+ Thread.current[:actor].proxy.async
+ end
end
# Handle calls to future within an actor itself
- def future(meth, *args, &block)
- Actor.future Thread.current[:actor].mailbox, meth, *args, &block
+ def future(meth = nil, *args, &block)
+ if meth
+ Actor.future Thread.current[:actor].mailbox, meth, *args, &block
+ else
+ Thread.current[:actor].proxy.future
+ end
end
end
require 'celluloid/version'