Class: Pallets::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/pallets/scheduler.rb

Instance Method Summary collapse

Constructor Details

#initialize(manager) ⇒ Scheduler

Returns a new instance of Scheduler.



3
4
5
6
7
# File 'lib/pallets/scheduler.rb', line 3

def initialize(manager)
  @manager = manager
  @needs_to_stop = false
  @thread = nil
end

Instance Method Details

#debugObject



24
25
26
# File 'lib/pallets/scheduler.rb', line 24

def debug
  @thread.backtrace
end

#idObject



28
29
30
# File 'lib/pallets/scheduler.rb', line 28

def id
  "S#{@thread.object_id.to_s(36)}".upcase if @thread
end

#needs_to_stop?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/pallets/scheduler.rb', line 20

def needs_to_stop?
  @needs_to_stop
end

#shutdownObject



13
14
15
16
17
18
# File 'lib/pallets/scheduler.rb', line 13

def shutdown
  @needs_to_stop = true

  return unless @thread
  @thread.join
end

#startObject



9
10
11
# File 'lib/pallets/scheduler.rb', line 9

def start
  @thread ||= Thread.new { work }
end