Class: Stackify::Worker
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name = nil) ⇒ Worker
Returns a new instance of Worker.
Instance Attribute Details
Returns the value of attribute name.
6
7
8
|
# File 'lib/stackify/workers/worker.rb', line 6
def name
@name
end
|
Returns the value of attribute type.
6
7
8
|
# File 'lib/stackify/workers/worker.rb', line 6
def type
@type
end
|
Instance Method Details
#alive? ⇒ Boolean
43
44
45
|
# File 'lib/stackify/workers/worker.rb', line 43
def alive?
@worker_thread.try(:alive?)
end
|
17
18
19
|
# File 'lib/stackify/workers/worker.rb', line 17
def async_perform period=ScheduleDelay.new, task
run_scheduler task, period
end
|
#backtrace ⇒ Object
39
40
41
|
# File 'lib/stackify/workers/worker.rb', line 39
def backtrace
@worker_thread.try(:backtrace)
end
|
47
48
49
|
# File 'lib/stackify/workers/worker.rb', line 47
def id
object_id
end
|
21
22
23
|
# File 'lib/stackify/workers/worker.rb', line 21
def perform period=ScheduleDelay.new, task
run_scheduler task, period, true
end
|
#shutdown! ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/stackify/workers/worker.rb', line 25
def shutdown!
Stackify.delete_worker self
if @worker_thread
Stackify.internal_log :debug, "Thread with name \"#{@name}\" is terminated!"
Thread.kill @worker_thread
else
Stackify.internal_log :warn, "Thread with name \"#{@name}\" is terminated with exception!"
end
end
|
35
36
37
|
# File 'lib/stackify/workers/worker.rb', line 35
def status
@worker_thread.try(:status)
end
|