class Rufus::Scheduler::Job

def trigger(t=Time.now)


Triggers the job.
def trigger(t=Time.now)
  @last = t
  job_thread = nil
  to_job = nil
  return if @running && !@allow_overlapping
  @running = true
  @scheduler.send(:trigger_job, @params[:blocking]) do
    #
    # Note that #trigger_job is protected, hence the #send
    # (Only jobs know about this method of the scheduler)
    job_thread = Thread.current
    job_thread[
      "rufus_scheduler__trigger_thread__#{@scheduler.object_id}"
    ] = true
    @last_job_thread = job_thread
    begin
      trigger_block
      job_thread = nil
      to_job.unschedule if to_job
      @running = false
    rescue Exception => e
      @scheduler.handle_exception(self, e)
    end
  end
  # note that add_job and add_cron_job ensured that :blocking is
  # not used along :timeout
  if to = @params[:timeout]
    to_job = @scheduler.in(to, :parent => self, :tags => 'timeout') do
      # at this point, @job_thread might be set
      if job_thread && job_thread.alive?
        job_thread.raise(Rufus::Scheduler::TimeOutError)
      end
    end
  end
end