lib/celluloid/actor.rb in celluloid-0.12.4.pre vs lib/celluloid/actor.rb in celluloid-0.12.4.pre2

- old
+ new

@@ -42,18 +42,18 @@ Registry.root.clear end # Obtain the current actor def current - actor = Thread.current[:celluloid_actor] + actor = Thread.current[:actor] raise NotActorError, "not in actor scope" unless actor actor.proxy end # Obtain the name of the current actor def name - actor = Thread.current[:celluloid_actor] + actor = Thread.current[:actor] raise NotActorError, "not in actor scope" unless actor actor.name end # Invoke a method on the given actor via its mailbox @@ -64,19 +64,19 @@ mailbox << call rescue MailboxError raise DeadActorError, "attempted to call a dead actor" end - if Thread.current[:celluloid_task] && !Celluloid.exclusive? + if Thread.current[:task] && !Celluloid.exclusive? Task.suspend(:callwait).value else response = loop do message = Thread.mailbox.receive do |msg| msg.respond_to?(:call) and msg.call == call end break message unless message.is_a?(SystemEvent) - Thread.current[:celluloid_actor].handle_system_event(message) + Thread.current[:actor].handle_system_event(message) end response.value end end @@ -102,48 +102,48 @@ # Obtain all running actors in the system def all actors = [] Thread.list.each do |t| - actor = t[:celluloid_actor] + actor = t[:actor] actors << actor.proxy if actor and actor.respond_to?(:proxy) end actors end # Watch for exit events from another actor def monitor(actor) raise NotActorError, "can't link outside actor context" unless Celluloid.actor? - Thread.current[:celluloid_actor].linking_request(actor, :link) + Thread.current[:actor].linking_request(actor, :link) end # Stop waiting for exit events from another actor def unmonitor(actor) raise NotActorError, "can't link outside actor context" unless Celluloid.actor? - Thread.current[:celluloid_actor].linking_request(actor, :unlink) + Thread.current[:actor].linking_request(actor, :unlink) end # Link to another actor def link(actor) monitor actor - Thread.current[:celluloid_actor].links << actor + Thread.current[:actor].links << actor end # Unlink from another actor def unlink(actor) unmonitor actor - Thread.current[:celluloid_actor].links.delete actor + Thread.current[:actor].links.delete actor end # Are we monitoring the given actor? def monitoring?(actor) actor.links.include? Actor.current end # Are we bidirectionally linked to the given actor? def linked_to?(actor) - monitoring?(actor) && Thread.current[:celluloid_actor].links.include?(actor) + monitoring?(actor) && Thread.current[:actor].links.include?(actor) end # Forcibly kill a given actor def kill(actor) actor.thread.kill @@ -177,12 +177,12 @@ @running = true @exclusive = false @name = nil @thread = ThreadHandle.new do - Thread.current[:celluloid_actor] = self - Thread.current[:celluloid_mailbox] = @mailbox + Thread.current[:actor] = self + Thread.current[:mailbox] = @mailbox run end @proxy = @proxy_class.new(self) @subject.instance_variable_set(OWNER_IVAR, self) @@ -307,11 +307,11 @@ @timers.every(interval) { task(:timer, &block) } end # Sleep for the given amount of time def sleep(interval) - task = Thread.current[:celluloid_task] + task = Thread.current[:task] if task && !Celluloid.exclusive? @timers.after(interval) { task.resume } Task.suspend :sleeping else Kernel.sleep(interval) @@ -370,11 +370,11 @@ # Handle cleaning up this actor after it exits def shutdown(exit_event = ExitEvent.new(@proxy)) run_finalizer cleanup exit_event ensure - Thread.current[:celluloid_actor] = nil - Thread.current[:celluloid_mailbox] = nil + Thread.current[:actor] = nil + Thread.current[:mailbox] = nil end # Run the user-defined finalizer, if one is set def run_finalizer return unless @subject.respond_to? :finalize