class Concurrent::ScheduledTask
def initialize(delay, opts = {}, &task)
-
(ArgumentError)
- When given a time that is in the past -
(ArgumentError)
- When no block is given
Options Hash:
(**opts)
-
:args
(object, Array
) -- zero or more arguments to be passed the task
Other tags:
- Yield: - the task to be performed
Parameters:
-
delay
(Float
) -- the number of seconds to wait for before executing the task
def initialize(delay, opts = {}, &task) raise ArgumentError.new('no block given') unless block_given? raise ArgumentError.new('seconds must be greater than zero') if delay.to_f < 0.0 super(NULL, opts, &nil) synchronize do ns_set_state(:unscheduled) @parent = opts.fetch(:timer_set, Concurrent.global_timer_set) @args = get_arguments_from(opts) @delay = delay.to_f @task = task @time = nil @executor = Options.executor_from_options(opts) || Concurrent.global_io_executor self.observers = Collection::CopyOnNotifyObserverSet.new end end