Class: Kommando::ScheduledCommandRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/kommando/scheduled_command_runner.rb

Constant Summary collapse

JITTER =
0.5
PAUSE =
5.0

Instance Method Summary collapse

Constructor Details

#initialize(number, adapter, dependencies) ⇒ ScheduledCommandRunner

Returns a new instance of ScheduledCommandRunner.



6
7
8
9
10
11
12
13
# File 'lib/kommando/scheduled_command_runner.rb', line 6

def initialize(number, adapter, dependencies)
  @number = number
  @adapter = adapter
  @dependencies = dependencies
  @thread = nil
  @stop_before_next_fetch = false
  @stopped = false
end

Instance Method Details

#killObject



27
28
29
# File 'lib/kommando/scheduled_command_runner.rb', line 27

def kill
  @thread.kill
end

#startObject



15
16
17
# File 'lib/kommando/scheduled_command_runner.rb', line 15

def start
  @thread ||= start_thread("runner-#{@number}", &method(:run))
end

#stop_before_next_fetchObject



19
20
21
# File 'lib/kommando/scheduled_command_runner.rb', line 19

def stop_before_next_fetch
  @stop_before_next_fetch = true
end

#stopped?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/kommando/scheduled_command_runner.rb', line 23

def stopped?
  @stopped
end