Sha256: 589bcfca9cd8dd83315554c7d8b8b2c1ddbde0af59d7bffebe554f32ee438b2f
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 Bytes
Contents
require 'thread' module Celluloid # The Registry allows us to refer to specific actors by human-meaningful names module Registry @@registry = {} @@registry_lock = Mutex.new # Register an Actor def []=(name, actor) actor_singleton = class << actor; self; end unless actor_singleton.ancestors.include? ActorProxy raise TypeError, "not an actor" end @@registry_lock.synchronize do @@registry[name.to_sym] = actor end actor.mailbox.system_event NamingRequest.new(name.to_sym) end # Retrieve an actor by name def [](name) @@registry_lock.synchronize do @@registry[name.to_sym] end end # List all registered actors by name def registered @@registry_lock.synchronize { @@registry.keys } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kulesa-celluloid-0.10.2 | lib/celluloid/registry.rb |