Class: Ethmo::Monitor
- Inherits:
-
Object
- Object
- Ethmo::Monitor
- Includes:
- Enumerable
- Defined in:
- lib/ethmo/monitor.rb,
lib/ethmo/monitor/new_head.rb
Overview
:nodoc:
Defined Under Namespace
Classes: NewHead
Instance Method Summary collapse
- #each(&_block) ⇒ Object
-
#initialize(type = 'newHeads') ⇒ Monitor
constructor
A new instance of Monitor.
- #start ⇒ Object
- #stop ⇒ Object
- #stop? ⇒ Boolean
Constructor Details
#initialize(type = 'newHeads') ⇒ Monitor
Returns a new instance of Monitor.
10 11 12 13 14 15 16 |
# File 'lib/ethmo/monitor.rb', line 10 def initialize(type = 'newHeads') @conn = IPCSocket.new(Config.socket) @type = type @thread = nil @stop = false @queue = Queue.new end |
Instance Method Details
#each(&_block) ⇒ Object
18 19 20 |
# File 'lib/ethmo/monitor.rb', line 18 def each(&_block) yield @queue.pop until stop? end |
#start ⇒ Object
22 23 24 25 26 |
# File 'lib/ethmo/monitor.rb', line 22 def start return if @thread subscribe! @thread = Thread.new { process until stop? } end |
#stop ⇒ Object
32 33 34 |
# File 'lib/ethmo/monitor.rb', line 32 def stop @stop = true end |
#stop? ⇒ Boolean
28 29 30 |
# File 'lib/ethmo/monitor.rb', line 28 def stop? @stop == true end |