Method: Concurrent::TimerSet#post
- Defined in:
- lib/concurrent/executor/timer_set.rb
#post(delay, *args) { ... } ⇒ Concurrent::ScheduledTask, false
Post a task to be execute run after a given delay (in seconds). If the delay is less than 1/100th of a second the task will be immediately post to the executor.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/concurrent/executor/timer_set.rb', line 48 def post(delay, *args, &task) raise ArgumentError.new('no block given') unless block_given? return false unless running? opts = { executor: @task_executor, args: args, timer_set: self } task = ScheduledTask.execute(delay, opts, &task) # may raise exception task.unscheduled? ? false : task end |