123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Cluster::PeriodicExecutor Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/mongo/cluster/periodic_executor.rb

Overview

A manager that calls #execute on its executors at a regular interval.

Since:

  • 2.5.0

Constant Summary

::Mongo::Loggable - Included

PREFIX

Class Method Summary

Instance Attribute Summary

::Mongo::BackgroundThread - Included

Instance Method Summary

::Mongo::BackgroundThread - Included

#run!

Start the background thread.

#stop!

Stop the background thread and wait for to terminate for a reasonable amount of time.

#do_work

Override this method to do the work in the background thread.

#pre_stop

Override this method to perform additional signaling for the background thread to stop.

#start!,
#wait_for_stop

Waits for the thread to die, with a timeout.

::Mongo::Loggable - Included

#log_debug

Convenience method to log debug messages with the standard prefix.

#log_error

Convenience method to log error messages with the standard prefix.

#log_fatal

Convenience method to log fatal messages with the standard prefix.

#log_info

Convenience method to log info messages with the standard prefix.

#log_warn

Convenience method to log warn messages with the standard prefix.

#logger

Get the logger instance.

#_mongo_log_prefix, #format_message

Instance Attribute Details

#options (readonly)

Since:

  • 2.5.0

[ GitHub ]

  
# File 'lib/mongo/cluster/periodic_executor.rb', line 54

attr_reader :options

Instance Method Details

#do_work

Since:

  • 2.5.0

[ GitHub ]

  
# File 'lib/mongo/cluster/periodic_executor.rb', line 58

def do_work
  execute
  @stop_semaphore.wait(FREQUENCY)
end

#execute

Trigger an execute call on each reaper.

Examples:

Trigger all reapers.

periodic_executor.execute

Since:

  • 2.5.0

[ GitHub ]

  
# File 'lib/mongo/cluster/periodic_executor.rb', line 86

def execute
  @executors.each(&:execute)
  true
end

#flush

Execute all pending operations.

Examples:

Execute all pending operations.

periodic_executor.flush

Since:

  • 2.5.0

[ GitHub ]

  
# File 'lib/mongo/cluster/periodic_executor.rb', line 99

def flush
  @executors.each(&:flush)
  true
end

#pre_stop

Since:

  • 2.5.0

[ GitHub ]

  
# File 'lib/mongo/cluster/periodic_executor.rb', line 63

def pre_stop
  @stop_semaphore.signal
end

#restart!

[ GitHub ]

  
# File 'lib/mongo/cluster/periodic_executor.rb', line 56

alias :restart! :run!

#stop(final = false)

Since:

  • 2.5.0

[ GitHub ]

  
# File 'lib/mongo/cluster/periodic_executor.rb', line 67

def stop(final = false)
  super

  begin
    flush
  rescue
  end

  true
end