Sha256: 1b81aa52222ef63d2d3ecead79148e7961a0a25e46057018514e053693501451
Contents?: true
Size: 1.28 KB
Versions: 12
Compression:
Stored size: 1.28 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 end
Version data entries
12 entries across 12 versions & 1 rubygems