Class: SDEE::Client
- Inherits:
-
Object
- Object
- SDEE::Client
- Defined in:
- lib/sdee/client.rb
Instance Method Summary collapse
-
#get ⇒ Object
Retrieves but doesn’t remove events from buffer.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#pop ⇒ Object
Removes events from buffer.
- #start_polling(num_threads = 5) ⇒ Object
- #stop_polling ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 |
# File 'lib/sdee/client.rb', line 6 def initialize(={}) = # buffer to retain alerts, threads @events = @threads = [] end |
Instance Method Details
#get ⇒ Object
Retrieves but doesn’t remove events from buffer
36 37 38 |
# File 'lib/sdee/client.rb', line 36 def get @events end |
#pop ⇒ Object
Removes events from buffer
31 32 33 |
# File 'lib/sdee/client.rb', line 31 def pop @events.delete end |
#start_polling(num_threads = 5) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sdee/client.rb', line 13 def start_polling(num_threads=5) stop_polling unless @threads.empty? num_threads.times do @threads << Thread.new do poller = Poller.new() poller.poll end end @threads.each { |t| t.join } end |
#stop_polling ⇒ Object
26 27 28 |
# File 'lib/sdee/client.rb', line 26 def stop_polling @threads.each { |thread| thread.terminate } end |