lib/stackify/workers/worker.rb in stackify-api-ruby-1.0.2 vs lib/stackify/workers/worker.rb in stackify-api-ruby-1.0.3

- old
+ new

@@ -11,22 +11,22 @@ @name += " ##{self.id}" @scheduler = Stackify::Scheduler.new Stackify.add_dependant_worker self end - def async_perform period=1.0, task + def async_perform period=ScheduleDelay.new, task run_scheduler task, period end - def perform period=1.0, task + def perform period=ScheduleDelay.new, task run_scheduler task, period, true end def shutdown! Stackify.delete_worker self if @worker_thread - Stackify.internal_log :info, "Thread with name \"#{@name}\" is terminated!" + 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 @@ -50,12 +50,12 @@ private def generate_name 'Untitled worker' end - def run_scheduler task, period, sync = false + def run_scheduler task, delay, sync = false @worker_thread = Thread.new do - @scheduler.run period, task + @scheduler.run delay, task after_perform @scheduler.task_result if respond_to? :after_perform shutdown! end @worker_thread.join if sync && @worker_thread.alive? end