Class: LogStash::Codecs::IdentityMapCodec::PeriodicRunner
- Inherits:
-
Object
- Object
- LogStash::Codecs::IdentityMapCodec::PeriodicRunner
- Defined in:
- lib/logstash/codecs/identity_map_codec.rb
Instance Method Summary collapse
-
#initialize(listener, interval, method_symbol) ⇒ PeriodicRunner
constructor
A new instance of PeriodicRunner.
- #running? ⇒ Boolean
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(listener, interval, method_symbol) ⇒ PeriodicRunner
Returns a new instance of PeriodicRunner.
42 43 44 45 46 |
# File 'lib/logstash/codecs/identity_map_codec.rb', line 42 def initialize(listener, interval, method_symbol) @listener, @interval = listener, interval @method_symbol = method_symbol @running = Concurrent::AtomicBoolean.new(false) end |
Instance Method Details
#running? ⇒ Boolean
62 63 64 |
# File 'lib/logstash/codecs/identity_map_codec.rb', line 62 def running? @running.true? end |
#start ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/logstash/codecs/identity_map_codec.rb', line 48 def start return self if running? @running.make_true @thread = Thread.new() do while running? do sleep @interval break if !running? break if @listener.nil? @listener.send(@method_symbol) end end self end |
#stop ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/logstash/codecs/identity_map_codec.rb', line 66 def stop return if !running? @running.make_false if @thread.alive? @thread.wakeup @thread.join end @listener = nil end |