Sha256: 4c73bf2bdfb6c92da12c3ded23e9990ed57dca06258737845ff46cc52f1ffc72

Contents?: true

Size: 761 Bytes

Versions: 74

Compression:

Stored size: 761 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
    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

74 entries across 74 versions & 2 rubygems

Version Path
engineyard-serverside-2.0.4 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.5 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.3 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.2 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.1 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.0 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.0.rc1 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.0.pre5 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.0.pre4 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.0.pre3 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.0.pre2 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-2.0.0.pre1 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.7.0.pre2 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.4 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.4.pre6 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.4.pre5 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.4.pre4 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.4.pre3 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.4.pre2 lib/vendor/celluloid/lib/celluloid/registry.rb
engineyard-serverside-1.6.4.pre lib/vendor/celluloid/lib/celluloid/registry.rb