Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Worker
- def perform_task(job_id, action, params={}, interrupt=false)
- if @pending_action && interrupt
- self.task_failed
- end
- @job_id = job_id
- self.move(params[:location] || self.position)
- @pending_action = Proc.new {
- self.send(action, params)
- }
- end
- def task_failed
- # Return :failed to jobmanager for @task_id
- self.clear_task
- end
- # It is implied (probably in the action definitions) that this method is called when a task has been completed
- def task_finished
- # Return :succeeded to jobmanager for @task_id
- self.clear_task
- end
- def clear_task
- @task_id = nil
- @pending_action = nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement