lib/celluloid.rb in celluloid-0.12.4.pre vs lib/celluloid.rb in celluloid-0.12.4.pre2
- old
+ new
@@ -22,11 +22,11 @@
klass.send :include, InstanceMethods
end
# Are we currently inside of an actor?
def actor?
- !!Thread.current[:celluloid_actor]
+ !!Thread.current[:actor]
end
# Generate a Universally Unique Identifier
def uuid
UUID.generate
@@ -254,11 +254,11 @@
def bare_object; self; end
alias_method :wrapped_object, :bare_object
# Are we being invoked in a different thread from our owner?
def leaked?
- @celluloid_owner != Thread.current[:celluloid_actor]
+ @celluloid_owner != Thread.current[:actor]
end
def inspect
str = "#<"
@@ -286,11 +286,11 @@
unbanged_meth = meth.to_s.sub(/!$/, '')
args.unshift unbanged_meth
call = AsyncCall.new(:__send__, args, block)
begin
- Thread.current[:celluloid_actor].mailbox << call
+ 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
# async calls should find other ways to deal with actors dying
# during an async call (i.e. linking/supervisors)
@@ -318,21 +318,21 @@
raise AbortError.new(cause)
end
# Terminate this actor
def terminate
- Thread.current[:celluloid_actor].terminate
+ Thread.current[:actor].terminate
end
# Send a signal with the given name to all waiting methods
def signal(name, value = nil)
- Thread.current[:celluloid_actor].signal name, value
+ Thread.current[:actor].signal name, value
end
# Wait for the given signal
def wait(name)
- Thread.current[:celluloid_actor].wait name
+ Thread.current[:actor].wait name
end
# Obtain the current_actor
def current_actor
Actor.current
@@ -343,16 +343,16 @@
Actor.name
end
# Obtain the running tasks for this actor
def tasks
- Thread.current[:celluloid_actor].tasks.to_a
+ Thread.current[:actor].tasks.to_a
end
# Obtain the Celluloid::Links for this actor
def links
- Thread.current[:celluloid_actor].links
+ Thread.current[:actor].links
end
# Watch for exit events from another actor
def monitor(actor)
Actor.monitor(actor)
@@ -383,48 +383,48 @@
Actor.linked_to?(actor)
end
# Receive an asynchronous message via the actor protocol
def receive(timeout = nil, &block)
- actor = Thread.current[:celluloid_actor]
+ actor = Thread.current[:actor]
if actor
actor.receive(timeout, &block)
else
Thread.mailbox.receive(timeout, &block)
end
end
# Sleep letting the actor continue processing messages
def sleep(interval)
- actor = Thread.current[:celluloid_actor]
+ actor = Thread.current[:actor]
if actor
actor.sleep(interval)
else
Kernel.sleep interval
end
end
# Run given block in an exclusive mode: all synchronous calls block the whole
# actor, not only current message processing.
def exclusive(&block)
- Thread.current[:celluloid_actor].exclusive(&block)
+ Thread.current[:actor].exclusive(&block)
end
# Are we currently exclusive
def exclusive?
- actor = Thread.current[:celluloid_actor]
+ actor = Thread.current[:actor]
actor && actor.exclusive?
end
# Call a block after a given interval, returning a Celluloid::Timer object
def after(interval, &block)
- Thread.current[:celluloid_actor].after(interval, &block)
+ Thread.current[:actor].after(interval, &block)
end
# Call a block every given interval, returning a Celluloid::Timer object
def every(interval, &block)
- Thread.current[:celluloid_actor].every(interval, &block)
+ Thread.current[:actor].every(interval, &block)
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
@@ -435,21 +435,21 @@
end
# Handle async calls within an actor itself
def async(meth = nil, *args, &block)
if meth
- Actor.async Thread.current[:celluloid_actor].mailbox, meth, *args, &block
+ Actor.async Thread.current[:actor].mailbox, meth, *args, &block
else
- Thread.current[:celluloid_actor].proxy.async
+ Thread.current[:actor].proxy.async
end
end
# Handle calls to future within an actor itself
def future(meth = nil, *args, &block)
if meth
- Actor.future Thread.current[:celluloid_actor].mailbox, meth, *args, &block
+ Actor.future Thread.current[:actor].mailbox, meth, *args, &block
else
- Thread.current[:celluloid_actor].proxy.future
+ Thread.current[:actor].proxy.future
end
end
end
require 'celluloid/version'