Sha256: 6ed79bbb7ec5f47afd0fe96a6108babd9883dfde994a25cb5d4fd5ba211fb0a2

Contents?: true

Size: 1.03 KB

Versions: 19

Compression:

Stored size: 1.03 KB

Contents

module Concurrent
  module Actor
    # implements the root actor
    class Root < AbstractContext

      def initialize
        # noinspection RubyArgCount
        @dead_letter_router = Core.new(parent:    reference,
                                       class:     DefaultDeadLetterHandler,
                                       supervise: true,
                                       name:      :default_dead_letter_handler).reference
      end

      # to allow spawning of new actors, spawn needs to be called inside the parent Actor
      def on_message(message)
        case
        when message.is_a?(::Array) && message.first == :spawn
          Actor.spawn message[1], &message[2]
        when message == :dead_letter_routing
          @dead_letter_router
        else
          # ignore
        end
      end

      def dead_letter_routing
        @dead_letter_router
      end

      def behaviour_definition
        [*Behaviour.base(:just_log),
         *Behaviour.supervising,
         *Behaviour.user_messages]
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
concurrent-ruby-edge-0.6.0 lib/concurrent-ruby-edge/concurrent/actor/root.rb
concurrent-ruby-edge-0.6.0.pre1 lib/concurrent-ruby-edge/concurrent/actor/root.rb
concurrent-ruby-edge-0.5.0 lib-edge/concurrent/actor/root.rb
concurrent-ruby-edge-0.4.1 lib-edge/concurrent/actor/root.rb
concurrent-ruby-edge-0.4.0.pre2 lib-edge/concurrent/actor/root.rb
concurrent-ruby-edge-0.4.0.pre1 lib-edge/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.4 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.3.1 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.3.0 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.3 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.3.pre3 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.2 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.1 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.0 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.0.pre5 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.0.pre4 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.0.pre3 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.0.pre2 lib/concurrent/actor/root.rb
concurrent-ruby-edge-0.2.0.pre1 lib/concurrent/actor/root.rb