Class: EvilEvents::Core::Events::Notifier::Worker Private

Inherits:
Abstract
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/evil_events/core/events/notifier/worker.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

Defined Under Namespace

Classes: Executor, Job

Constant Summary collapse

MAIN_THREAD_POLICY =

Since:

  • 0.3.0

:main_thread
IGNORANCE_POLICY =

Since:

  • 0.3.0

:ignorance
EXCEPTION_POLICY =

Since:

  • 0.3.0

:exception

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#restart!, #shutdown!

Constructor Details

#initialize(min_threads:, max_threads:, max_queue:, fallback_policy: MAIN_THREAD_POLICY) ⇒ Worker

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Worker.

Parameters:

  • min_threads (Hash)

    a customizable set of options

  • max_threads (Hash)

    a customizable set of options

  • max_queue (Hash)

    a customizable set of options

  • fallback_policy (Hash) (defaults to: MAIN_THREAD_POLICY)

    a customizable set of options

Options Hash (min_threads:):

  • (Integer)

Options Hash (max_threads:):

  • (Integer)

Options Hash (max_queue:):

  • (Integer)

Options Hash (fallback_policy:):

  • (Symbol)

See Also:

Since:

  • 0.3.0



40
41
42
43
44
45
46
47
# File 'lib/evil_events/core/events/notifier/worker.rb', line 40

def initialize(min_threads:, max_threads:, max_queue:, fallback_policy: MAIN_THREAD_POLICY)
  @executor = Executor.new(
    min_threads:     min_threads,
    max_threads:     max_threads,
    max_queue:       max_queue,
    fallback_policy: fallback_policy
  )
end

Instance Attribute Details

#executorEvilEvents::Core::Events::Notifier::Worker::Executor (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/evil_events/core/events/notifier/worker.rb', line 29

def executor
  @executor
end

Instance Method Details

#notify(manager, event) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



54
55
56
57
58
# File 'lib/evil_events/core/events/notifier/worker.rb', line 54

def notify(manager, event)
  event.__call_before_hooks__
  manager.subscribers.each { |subscriber| schedule_job(event, subscriber) }
  event.__call_after_hooks__
end

#schedule_job(event, subscriber) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



67
68
69
# File 'lib/evil_events/core/events/notifier/worker.rb', line 67

def schedule_job(event, subscriber)
  executor.execute(Job.new(event, subscriber))
end