Class: Linedump::Consumer
- Inherits:
-
Object
- Object
- Linedump::Consumer
show all
- Defined in:
- lib/linedump/consumer.rb
Defined Under Namespace
Classes: ReloadSignal, StopSignal
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Consumer.
12
13
14
15
16
|
# File 'lib/linedump/consumer.rb', line 12
def initialize
@streams = []
@lock = Mutex.new
@worker = nil
end
|
Instance Method Details
#is_registered?(_stream) ⇒ Boolean
23
24
25
|
# File 'lib/linedump/consumer.rb', line 23
def is_registered?(_stream)
not find_stream_wrapper(_stream).nil?
end
|
#register_stream(_stream, &_block) ⇒ Object
18
19
20
21
|
# File 'lib/linedump/consumer.rb', line 18
def register_stream(_stream, &_block)
streams << StreamWrapper.new(_stream, _block)
end
|
#reload ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/linedump/consumer.rb', line 27
def reload
@lock.synchronize do
if @worker and @worker.alive?
@worker.raise ReloadSignal else
@worker = load_worker
end
end
end
|
#stop ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/linedump/consumer.rb', line 37
def stop
@lock.synchronize do
if @worker and @worker.alive?
@worker.raise StopSignal
end
end
end
|