Sha256: 5ed53c43e635acc04119a8b3132b61932167b37ee5f4a7d73dd905d8131347c7
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Celluloid module Proxy # A proxy which controls the Actor lifecycle class Actor < Abstract attr_reader :thread, :mailbox # Used for reflecting on proxy objects themselves def __class__ Proxy::Actor end def initialize(thread, mailbox) @thread = thread @mailbox = mailbox end def inspect # TODO: use a system event to fetch actor state: tasks? "#<Celluloid::Proxy::Actor(#{@mailbox.address}) alive>" rescue DeadActorError "#<Celluloid::Proxy::Actor(#{@mailbox.address}) dead>" end def alive? @mailbox.alive? end def dead? !alive? end # Terminate the associated actor def terminate terminate! ::Celluloid::Actor.join(self) nil end # Terminate the associated actor asynchronously def terminate! ::Kernel.raise DeadActorError, "actor already terminated" unless alive? @mailbox << TerminationRequest.new end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
celluloid-0.17.0 | lib/celluloid/proxy/actor.rb |