Class: LogStash::Outputs::Kusto::Interval
- Inherits:
-
Object
- Object
- LogStash::Outputs::Kusto::Interval
- Defined in:
- lib/logstash/outputs/kusto/interval.rb
Overview
Bare-bones utility for running a block of code at an interval.
Class Method Summary collapse
-
.start(interval, procsy) ⇒ Interval
Initializes a new Interval with the given arguments and starts it before returning it.
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(interval, procsy) ⇒ Interval
constructor
A new instance of Interval.
-
#start ⇒ void
Starts the interval, or returns if it has already been started.
-
#stop ⇒ Object
Stop the interval.
Constructor Details
#initialize(interval, procsy) ⇒ Interval
Returns a new instance of Interval.
28 29 30 31 32 33 34 35 |
# File 'lib/logstash/outputs/kusto/interval.rb', line 28 def initialize(interval, procsy) @interval = interval @procsy = procsy # Mutex, ConditionVariable, etc. @mutex = Mutex.new @sleeper = ConditionVariable.new end |
Class Method Details
.start(interval, procsy) ⇒ Interval
Initializes a new Interval with the given arguments and starts it before returning it.
21 22 23 |
# File 'lib/logstash/outputs/kusto/interval.rb', line 21 def self.start(interval, procsy) new(interval, procsy).tap(&:start) end |
Instance Method Details
#alive? ⇒ Boolean
62 63 64 |
# File 'lib/logstash/outputs/kusto/interval.rb', line 62 def alive? @thread && @thread.alive? end |
#start ⇒ void
This method returns an undefined value.
Starts the interval, or returns if it has already been started.
41 42 43 44 45 46 47 |
# File 'lib/logstash/outputs/kusto/interval.rb', line 41 def start @mutex.synchronize do return if @thread && @thread.alive? @thread = Thread.new { run } end end |
#stop ⇒ Object
Stop the interval. Does not interrupt if execution is in-progress.
52 53 54 55 56 57 58 |
# File 'lib/logstash/outputs/kusto/interval.rb', line 52 def stop @mutex.synchronize do @stopped = true end @thread && @thread.join end |