Class: Mongo::Cluster::PeriodicExecutor Private
- Inherits:
-
Object
- Object
- Mongo::Cluster::PeriodicExecutor
- Includes:
- BackgroundThread
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.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.
A manager that calls #execute on its executors at a regular interval.
Constant Summary collapse
- FREQUENCY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The default time interval for the periodic executor to execute.
5
Constants included from Loggable
Instance Attribute Summary collapse
- #options ⇒ Object readonly private
Instance Method Summary collapse
- #do_work ⇒ Object private
-
#execute ⇒ Object
private
Trigger an execute call on each reaper.
-
#flush ⇒ Object
private
Execute all pending operations.
-
#initialize(executors, options = {}) ⇒ PeriodicExecutor
constructor
private
Create a periodic executor.
- #pre_stop ⇒ Object private
- #stop(final = false) ⇒ Object private
Methods included from BackgroundThread
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Constructor Details
#initialize(executors, options = {}) ⇒ PeriodicExecutor
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.
Create a periodic executor.
47 48 49 50 51 52 |
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.rb', line 47 def initialize(executors, = {}) @thread = nil @executors = executors @stop_semaphore = Semaphore.new @options = end |
Instance Attribute Details
#options ⇒ Object (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.
54 55 56 |
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.rb', line 54 def @options end |
Instance Method Details
#do_work ⇒ 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.
58 59 60 61 |
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.rb', line 58 def do_work execute @stop_semaphore.wait(FREQUENCY) end |
#execute ⇒ 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.
Trigger an execute call on each reaper.
86 87 88 89 |
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.rb', line 86 def execute @executors.each(&:execute) true end |
#flush ⇒ 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.
Execute all pending operations.
99 100 101 102 |
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.rb', line 99 def flush @executors.each(&:flush) true end |
#pre_stop ⇒ 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.
63 64 65 |
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.rb', line 63 def pre_stop @stop_semaphore.signal end |
#stop(final = false) ⇒ 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.
67 68 69 70 71 72 73 74 75 76 |
# File 'build/ruby-driver-v2.19/lib/mongo/cluster/periodic_executor.rb', line 67 def stop(final = false) super begin flush rescue end true end |