PeriodicExecutor — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Cluster::PeriodicExecutorPrivate

Inherits:

Object

Includes:

BackgroundThread

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 Summarycollapse

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

Loggable::PREFIX

Instance Attribute Summary collapse

Instance Method Summarycollapse

Methods included from BackgroundThread

#run!, #running?, #stop!

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 'lib/mongo/cluster/periodic_executor.rb', line 47 def initialize(executors, options = {}) @thread = nil @executors = executors @stop_semaphore = Semaphore.new @options = options end

Instance Attribute Details

#options ⇒ 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 # File 'lib/mongo/cluster/periodic_executor.rb', line 54 def options @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 '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 '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 '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 '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 'lib/mongo/cluster/periodic_executor.rb', line 67 def stop(final = false) super begin flush rescue end true end