Sha256: 4f3c6acd93ed978ef3736024fec97f83d538da4aeb2e1bc294d623a08470943b
Contents?: true
Size: 1.1 KB
Versions: 70
Compression:
Stored size: 1.1 KB
Contents
module Redcar class Task include java.util.concurrent.Callable attr_accessor :_queue, :enqueue_time, :start_time, :completed_time, :description attr_reader :error def pending? @enqueue_time and !@start_time end def in_process? @start_time and !@completed_time end def completed? @completed_time end def cancel @cancelled = true _queue.send(:completed_task, self) end def cancelled? @cancelled end def call begin unless cancelled? _queue.send(:started_task, self) @start_time = Time.now result = execute @completed_time = Time.now _queue.send(:completed_task, self) result end rescue Object => e @error = e @completed_time = Time.now _queue.send(:completed_task, self) nil end end def execute raise "implement me!" end def inspect "<Task>" end private def _set_cancelled @cancelled = true end end end
Version data entries
70 entries across 70 versions & 2 rubygems