lib/celluloid.rb in celluloid-0.7.2 vs lib/celluloid.rb in celluloid-0.8.0

- old
+ new

@@ -41,17 +41,10 @@ actor.sleep(interval) else Kernel.sleep interval end end - - # Obtain a hash of active tasks to their current activities - def tasks - actor = Thread.current[:actor] - raise NotActorError, "not in actor scope" unless actor - actor.tasks - end end # Class methods added to classes which include Celluloid module ClassMethods # Create a new actor @@ -148,11 +141,11 @@ Celluloid.current_actor end # Obtain the running tasks for this actor def tasks - Celluloid.tasks + Thread.current[:actor].tasks.to_a end # Obtain the Ruby object the actor is wrapping. This should ONLY be used # for a limited set of use cases like runtime metaprogramming. Interacting # directly with the wrapped object foregoes any kind of thread safety that @@ -206,16 +199,21 @@ end # Perform a blocking or computationally intensive action inside an # asynchronous thread pool, allowing the caller to continue processing other # messages in its mailbox in the meantime - def async(&block) + def defer(&block) # This implementation relies on the present implementation of # Celluloid::Future, which uses an Actor to run the block Future.new(&block).value end + # Deprecated, do not use + def async + raise "Celluloid#async is defunct. Please use #defer instead" + end + # Process async calls via method_missing def method_missing(meth, *args, &block) # bang methods are async calls if meth.to_s.match(/!$/) unbanged_meth = meth.to_s.sub(/!$/, '') @@ -251,11 +249,11 @@ require 'celluloid/registry' require 'celluloid/responses' require 'celluloid/signals' require 'celluloid/task' require 'celluloid/timers' +require 'celluloid/thread_pool' require 'celluloid/actor' -require 'celluloid/actor_pool' -require 'celluloid/supervisor' require 'celluloid/future' -require 'celluloid/application' +require 'celluloid/group' +require 'celluloid/supervisor'