class Concurrent::Delay

def execute_task_once # :nodoc:

:nodoc:
@!visibility private
def execute_task_once # :nodoc:
  # this function has been optimized for performance and
  # should not be modified without running new benchmarks
  execute = task = nil
  synchronize do
    execute = @evaluation_started = true unless @evaluation_started
    task    = @task
  end
  if execute
    executor = Options.executor_from_options(executor: @executor)
    executor.post do
      begin
        result  = task.call
        success = true
      rescue => ex
        reason = ex
      end
      synchronize do
        set_state(success, result, reason)
        event.set
      end
    end
  end
end