class Employer::Employees::ThreadingEmployee
Public Instance Methods
force_work_stop()
click to toggle source
# File lib/employer/employees/threading_employee.rb, line 31 def force_work_stop return if free? @thread.kill @work_state = :failed end
free()
click to toggle source
Calls superclass method
Employer::Employees::AbstractEmployee#free
# File lib/employer/employees/threading_employee.rb, line 21 def free super @thread = nil end
work(job)
click to toggle source
Calls superclass method
Employer::Employees::AbstractEmployee#work
# File lib/employer/employees/threading_employee.rb, line 6 def work(job) super @work_state = :busy @thread = Thread.new do begin perform_job @work_state = :complete rescue => exception ensure @work_state = :failed if @work_state == :busy end end end
work_state(wait = false)
click to toggle source
# File lib/employer/employees/threading_employee.rb, line 26 def work_state(wait = false) @thread.join if wait && @thread return @work_state end