Sha256: 6c39aedb72bde80ca4163ab21209641737d8f78e750d9349bceb7c25fa9f04b0

Contents?: true

Size: 1.5 KB

Versions: 17

Compression:

Stored size: 1.5 KB

Contents

module Celluloid
  # High-priority internal system events
  class SystemEvent; end

  # Request to link with another actor
  class LinkingRequest < SystemEvent
    attr_reader :actor, :type

    def initialize(actor, type)
      @actor, @type = actor, type.to_sym
      raise ArgumentError, "type must be link or unlink" unless [:link, :unlink].include?(@type)
    end

    def process(links)
      case type
      when :link   then links << actor
      when :unlink then links.delete actor
      end

      actor.mailbox << LinkingResponse.new(Actor.current, type)
    end
  end

  # Response to a link request
  class LinkingResponse
    attr_reader :actor, :type

    def initialize(actor, type)
      @actor, @type = actor, type.to_sym
      raise ArgumentError, "type must be link or unlink" unless [:link, :unlink].include?(@type)
    end
  end

  # An actor has exited for the given reason
  class ExitEvent < SystemEvent
    attr_reader :actor, :reason

    def initialize(actor, reason = nil)
      @actor, @reason = actor, reason
    end
  end

  # Name an actor at the time it's registered
  class NamingRequest < SystemEvent
    attr_reader :name

    def initialize(name)
      @name = name
    end
  end

  # Request for an actor to terminate
  class TerminationRequest < SystemEvent; end

  # Signal a condition
  class SignalConditionRequest < SystemEvent
    def initialize(task, value)
      @task, @value = task, value
    end
    attr_reader :task, :value

    def call
      @task.resume(@value)
    end
  end
end

Version data entries

17 entries across 15 versions & 5 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/celluloid-0.16.0/lib/celluloid/system_events.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/system_events.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/celluloid-0.16.0/lib/celluloid/system_events.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/celluloid-0.16.0/lib/celluloid/system_events.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/celluloid-0.16.0/lib/celluloid/system_events.rb
celluloid-0.16.0 lib/celluloid/system_events.rb
celluloid-0.16.0.pre3 lib/celluloid/system_events.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/celluloid-0.15.2/lib/celluloid/system_events.rb
celluloid-0.16.0.pre2 lib/celluloid/system_events.rb
celluloid-0.16.0.pre lib/celluloid/system_events.rb
celluloid-0.15.2 lib/celluloid/system_events.rb
celluloid-0.15.1 lib/celluloid/system_events.rb
celluloid-0.15.0 lib/celluloid/system_events.rb
celluloid-0.15.0.pre2 lib/celluloid/system_events.rb
celluloid-0.15.0.pre lib/celluloid/system_events.rb
celluloid-0.14.1 lib/celluloid/system_events.rb
celluloid-0.14.1.pre lib/celluloid/system_events.rb