Sha256: 8b5b1fdc5a2e37d2137a96e3dbddd518ffcd60c1e45134f77edbcbdda776961f

Contents?: true

Size: 757 Bytes

Versions: 4

Compression:

Stored size: 757 Bytes

Contents

module Proletariat
  class Supervisor
    extend Forwardable

    def_delegators :true_supervisor, :run, :run!, :stop, :running?, :add_worker

    def [](mailbox_name)
      mailboxes[mailbox_name]
    end

    def add_supervisor(supervisor, opts = {})
      true_supervisor.add_worker supervisor, opts.merge(type: :supervisor)
    end

    def supervise_pool(mailbox_name, threads, actor_class, *arguments)
      mailboxes[mailbox_name], workers = Actor.pool(threads, actor_class,
                                                    *arguments)
      true_supervisor.add_workers workers
    end

    private

    def mailboxes
      @mailboxes ||= {}
    end

    def true_supervisor
      @true_supervisor ||= Concurrent::Supervisor.new
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
proletariat-0.0.6 lib/proletariat/concurrency/supervisor.rb
proletariat-0.0.5 lib/proletariat/concurrency/supervisor.rb
proletariat-0.0.4 lib/proletariat/concurrency/supervisor.rb
proletariat-0.0.3 lib/proletariat/concurrency/supervisor.rb