class RocketJob::ThreadWorker
A worker runs on a single operating system thread. Is usually started under a Rocket Job
server process.
Attributes
thread[R]
Public Class Methods
new(id:, server_name:)
click to toggle source
Calls superclass method
# File lib/rocket_job/thread_worker.rb, line 10 def initialize(id:, server_name:) super(id: id, server_name: server_name) @shutdown = Concurrent::Event.new @thread = Thread.new { run } end
Public Instance Methods
alive?()
click to toggle source
# File lib/rocket_job/thread_worker.rb, line 16 def alive? @thread.alive? end
backtrace()
click to toggle source
# File lib/rocket_job/thread_worker.rb, line 20 def backtrace @thread.backtrace end
join(*args)
click to toggle source
# File lib/rocket_job/thread_worker.rb, line 24 def join(*args) @thread.join(*args) end
kill()
click to toggle source
Send each active worker the RocketJob::ShutdownException so that stops processing immediately.
# File lib/rocket_job/thread_worker.rb, line 29 def kill @thread.raise(Shutdown, "Shutdown due to kill request for worker: #{name}") if @thread.alive? end
shutdown!()
click to toggle source
# File lib/rocket_job/thread_worker.rb, line 37 def shutdown! @shutdown.set end
shutdown?()
click to toggle source
# File lib/rocket_job/thread_worker.rb, line 33 def shutdown? @shutdown.set? end
wait_for_shutdown?(timeout = nil)
click to toggle source
Returns [true|false] whether the shutdown indicator was set
# File lib/rocket_job/thread_worker.rb, line 42 def wait_for_shutdown?(timeout = nil) @shutdown.wait(timeout) end