Sha256: 6a939f1fd9b44d4f0b993dcb6b5559637ffc7f3ea121200f6cc1bf79a3df642c

Contents?: true

Size: 820 Bytes

Versions: 3

Compression:

Stored size: 820 Bytes

Contents

module Celluloid
  module Internals
    # Linked actors send each other system events
    class Links
      include Enumerable

      def initialize
        @links = {}
      end

      # Add an actor to the current links
      def <<(actor)
        @links[actor.mailbox.address] = actor
      end

      # Do links include the given actor?
      def include?(actor)
        @links.has_key? actor.mailbox.address
      end

      # Remove an actor from the links
      def delete(actor)
        @links.delete actor.mailbox.address
      end

      # Iterate through all links
      def each
        @links.each { |_, actor| yield(actor) }
      end

      # Generate a string representation
      def inspect
        links = self.map(&:inspect).join(',')
        "#<#{self.class}[#{links}]>"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
celluloid-essentials-0.20.0.pre14 lib/celluloid/internals/links.rb
celluloid-essentials-0.20.0.pre13 lib/celluloid/internals/links.rb
celluloid-essentials-0.20.0.pre12 lib/celluloid/internals/links.rb