dequeues the earliest occurrence from this clock or any child clocks.
 returns nil if it wasn't there, or its relative_time otherwise
971708
def unschedule(obj)
      if @occurrences.has_key? obj
        last_priority = @occurrences.min_priority
        obj, time = @occurrences.delete obj
        if parent && @occurrences.min_priority != last_priority
          if @occurrences.min_priority
            parent.schedule([:clock, self], unscale_time(@occurrences.min_priority))
          else
            parent.unschedule([:clock, self])
          end
        end
        unscale_time(time)
      else
        relative_time = @children.first_non_nil { |clock| clock.unschedule(obj) }
        unscale_relative_time(relative_time) if relative_time
      end
    end
72446
def dequeue
      _, line = RRRSpec.redis.blpop(PERSISTER_QUEUE_KEY, 0)
      Taskset.new(line)
    end
719675
def last_time
      execution_time = SidekiqScheduler::RedisManager.get_job_last_time(name)

      relative_time(Time.parse(execution_time)) if execution_time
    end
1179788
def _occursOn(self, myDate):
        
        # TODO analyse which is faster (rrule or db) and test that first
        if myDate not in self.repeat:
            return False
        if CancellationPage.events.child_of(self)                            \
                           .filter(except_date=myDate).exists():
            return False
        return True
262909
def -(other)
      if other.instance_of?(TimeOfDay)
        TimeOfDay.from_second_of_day @second_of_day - other.second_of_day
      else
        TimeOfDay.from_second_of_day @second_of_day - other
      end
    end
30067
def last_time_non_ok_or_up(self):
        
        non_ok_times = [x for x in [self.last_time_down]
                        if x > self.last_time_up]
        if not non_ok_times:
            last_time_non_ok = 0  # todo: program_start would be better?
        else:
            last_time_non_ok = min(non_ok_times)
        return last_time_non_ok
1356130
def run_one
      shred, relative_time = @clock.unschedule_next
      return nil unless shred
      
      fast_forward(relative_time) if relative_time > 0
      invoke_shred(shred)
    end
92928
def last(from: nil, to: nil, &block)
      retval = nil

      each_with_depth(from: from, to: nil) do |line, depth, index|
        retval = line if block.call(line, depth, index)
      end

      retval
    end
1041972
def order_by_first_occurrence(self):
        
        def _key(e):
            try:
                return e.occurrence_list[0].start
            except IndexError: # no occurrences; put last
                return localize(datetime.max - timedelta(days=365))

        return sorted(list(self), key=_key)
663710
def dequeue_task(timeout)
      if timeout < 0
        task_key = RRRSpec.redis.lpop(RRRSpec.make_key(key, 'task_queue'))
      else
        _, task_key = RRRSpec.redis.blpop(RRRSpec.make_key(key, 'task_queue'), timeout)
      end
      return nil unless task_key
      Task.new(task_key)
    end
308144
def rlgt(self, time=None, times=1,
             disallow_sibling_lgts=False):
        

        lgt = LGT(self.copy())
        for _ in range(times):
            lgt.rlgt(time, disallow_sibling_lgts)
        return lgt.tree
1223674
def remove_from_parent(self):
        '''
        
        '''
        if self.parent:
            self.parent._children.remove(self)
            self.parent._invalidate_time_caches()
            self.parent = None
89280
def parse_relative_time(time, in_ms = false)
      unless valid_relative_time?(time)
        raise Wavefront::Exception::InvalidRelativeTime
      end

      m = in_ms ? 1000 : 1
      time.delete!('+')
      match = time.match(/^(-?\d*\.?\d*)([smhdwy])$/)
      (match[1].to_f * time_multiplier(match[2]) * m).to_i
    end
999674
private E dequeue() {
        int n = size - 1;
        if (n < 0)
            return null;
        else {
            Object[] array = queue;
            E result = (E) array[0];
            E x = (E) array[n];
            array[n] = null;
            Comparator<? super E> cmp = comparator;
            if (cmp == null)
                siftDownComparable(0, x, array, n);
            else
                siftDownUsingComparator(0, x, array, n, cmp);
            size = n;
            return result;
        }
    }
360045
def next_run_in(self, utc_now=None):
        
        if utc_now is None:
            utc_now = datetime.utcnow()

        if self.is_alive():
            smallest_timedelta = timedelta(days=99, hours=0, minutes=0, seconds=0, microseconds=0, milliseconds=0)
            for event_time in self.timestamps:
                next_trigger = event_time.next_trigger_frequency(utc_now)
                if next_trigger - utc_now < smallest_timedelta:
                    smallest_timedelta = next_trigger - utc_now
            return smallest_timedelta

        else:
            return None
1226655
def syscall_removequeue(queue, index):
    '''
    
    '''
    def _syscall(scheduler, processor):
        events = scheduler.queue.unblockqueue(queue[index])
        for e in events:
            scheduler.eventtree.remove(e)
        qes, qees = queue.removeSubQueue(index)
        for e in qes:
            processor(e)
        for e in qees:
            processor(e)
    return _syscall
928868
private E dequeue() {
        // assert takeLock.isHeldByCurrentThread();
        // assert head.item == null;
        Node<E> h = head;
        Node<E> first = h.next;
        h.next = sentinel(); // help GC
        head = first;
        E x = first.item;
        first.item = null;
        return x;
    }