Class: Heathrow::Poller
- Inherits:
-
Object
- Object
- Heathrow::Poller
- Defined in:
- lib/heathrow/poller.rb
Instance Attribute Summary collapse
-
#running ⇒ Object
readonly
Returns the value of attribute running.
Instance Method Summary collapse
-
#initialize(db, plugin_manager) ⇒ Poller
constructor
A new instance of Poller.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(db, plugin_manager) ⇒ Poller
Returns a new instance of Poller.
8 9 10 11 12 13 14 |
# File 'lib/heathrow/poller.rb', line 8 def initialize(db, plugin_manager) @db = db @plugin_manager = plugin_manager @running = false @thread = nil @mutex = Mutex.new end |
Instance Attribute Details
#running ⇒ Object (readonly)
Returns the value of attribute running.
6 7 8 |
# File 'lib/heathrow/poller.rb', line 6 def running @running end |
Instance Method Details
#start ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/heathrow/poller.rb', line 16 def start return if @running @running = true @thread = Thread.new do run_polling_loop end end |
#stop ⇒ Object
25 26 27 28 |
# File 'lib/heathrow/poller.rb', line 25 def stop @running = false @thread&.join(5) # Wait up to 5 seconds for thread to finish end |