Class: Mongo::Cluster::PeriodicExecutor Private
- Inherits:
-
Object
- Object
- Mongo::Cluster::PeriodicExecutor
- Defined in:
- 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
Instance Method Summary collapse
-
#execute ⇒ Object
private
Trigger an execute call on each reaper.
-
#flush ⇒ Object
private
Execute all pending operations.
-
#initialize(*executors) ⇒ PeriodicExecutor
constructor
private
Create a periodic executor.
-
#run! ⇒ Object
(also: #restart!)
private
Start the thread.
-
#stop!(wait = false) ⇒ Object
private
Stop the executor’s thread.
Constructor Details
#initialize(*executors) ⇒ 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.
39 40 41 42 |
# File 'lib/mongo/cluster/periodic_executor.rb', line 39 def initialize(*executors) @thread = nil @executors = executors end |
Instance Method Details
#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.
85 86 87 |
# File 'lib/mongo/cluster/periodic_executor.rb', line 85 def execute @executors.each(&:execute) and 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.
97 98 99 |
# File 'lib/mongo/cluster/periodic_executor.rb', line 97 def flush @executors.each(&:flush) and true end |
#run! ⇒ Object Also known as: restart!
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.
Start the thread.
52 53 54 |
# File 'lib/mongo/cluster/periodic_executor.rb', line 52 def run! @thread && @thread.alive? ? @thread : start! end |
#stop!(wait = 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.
Stop the executor’s thread.
68 69 70 71 72 73 74 75 |
# File 'lib/mongo/cluster/periodic_executor.rb', line 68 def stop!(wait=false) begin; flush; rescue; end @thread.kill if wait @thread.join end !@thread.alive? end |