Sha256: e06106693d353afe5931dd621a6c1d3bf64eae4ee15dcb0b73e9423df3567591

Contents?: true

Size: 1.32 KB

Versions: 35

Compression:

Stored size: 1.32 KB

Contents

module Concurrent
  module Actor
    module Behaviour
      class Abstract
        include TypeCheck
        include InternalDelegations

        attr_reader :core, :subsequent

        def initialize(core, subsequent)
          @core       = Type! core, Core
          @subsequent = Type! subsequent, Abstract, NilClass
        end

        # override to add extra behaviour
        # @note super needs to be called not to break the chain
        def on_envelope(envelope)
          pass envelope
        end

        # @param [Envelope] envelope to pass to {#subsequent} behaviour
        def pass(envelope)
          subsequent.on_envelope envelope
        end

        # override to add extra behaviour
        # @note super needs to be called not to break the chain
        def on_event(event)
          subsequent.on_event event if subsequent
        end

        # broadcasts event to all behaviours and context
        # @see #on_event
        # @see AbstractContext#on_event
        def broadcast(event)
          core.broadcast(event)
        end

        def reject_envelope(envelope)
          envelope.reject! ActorTerminated.new(reference)
          dead_letter_routing << envelope unless envelope.ivar
          log Logging::DEBUG, "rejected #{envelope.message} from #{envelope.sender_path}"
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
concurrent-ruby-0.8.0 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.8.0-java lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.2 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.2-x86_64-linux lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.2-x86-solaris-2.11 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.2-x86-mingw32 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.2-x86-linux lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.2-x64-mingw32 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.2-java lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.8.0.pre2 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.8.0.pre2-java lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.8.0.pre1 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.8.0.pre1-java lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.1 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.1-x86_64-linux lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.1-x86-solaris-2.11 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.1-x86-mingw32 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.1-x86-linux lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.1-x64-mingw32 lib/concurrent/actor/behaviour/abstract.rb
concurrent-ruby-0.7.1-java lib/concurrent/actor/behaviour/abstract.rb