Module: RedisRing::BackgroundThread
- Included in:
- ProcessManager, WebInterfaceRunner, ZookeeperObserver
- Defined in:
- lib/redis_ring/background_thread.rb
Instance Method Summary collapse
- #after_halt ⇒ Object
- #before_run ⇒ Object
- #continue_running? ⇒ Boolean
- #do_work ⇒ Object
- #halt ⇒ Object
- #run ⇒ Object
Instance Method Details
#after_halt ⇒ Object
8 9 |
# File 'lib/redis_ring/background_thread.rb', line 8 def after_halt end |
#before_run ⇒ Object
5 6 |
# File 'lib/redis_ring/background_thread.rb', line 5 def before_run end |
#continue_running? ⇒ Boolean
35 36 37 |
# File 'lib/redis_ring/background_thread.rb', line 35 def continue_running? @continue_running end |
#do_work ⇒ Object
11 12 |
# File 'lib/redis_ring/background_thread.rb', line 11 def do_work end |
#halt ⇒ Object
39 40 41 |
# File 'lib/redis_ring/background_thread.rb', line 39 def halt @continue_running = false end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/redis_ring/background_thread.rb', line 14 def run before_run @continue_running = true return Thread.new do begin while continue_running? do_work end after_halt rescue SystemExit raise rescue => e puts "Error caught in #{self.class.name}:" puts e puts e.backtrace.join("\n") end end end |