// Delete timer t from the heap.
// Do not need to update the timerproc: if it wakes up early, no big deal.
553866
func deltimer(t *Timer) bool {
	// Dereference t so that any panic happens before the lock is held.
	// Discard result, because t might be moving in the heap.
	_ = t.i

	timers.lock.Lock()
	// t may not be registered anymore and may have
	// a bogus i (typically 0, if generated by Go).
	// Verify it before proceeding.
	i := t.i
	last := len(timers.t) - 1
	if i < 0 || i > last || timers.t[i] != t {
		timers.lock.Unlock()
		return false
	}
	if i != last {
		timers.t[i] = timers.t[last]
		timers.t[i].i = i
	}
	timers.t[last] = nil
	timers.t = timers.t[:last]
	if i != last {
		siftupTimer(i)
		siftdownTimer(i)
	}
	timers.lock.Unlock()
	return true
}
855875
func (tt *TimerToken) Stop() time.Duration {
	duration := time.Since(tt.Start)
	tt.MetricSystem.Histogram(tt.Name, float64(duration.Nanoseconds()))
	return duration
}
28010
func (f *Factory) Timer(options metrics.TimerOptions) metrics.Timer {
	help := strings.TrimSpace(options.Help)
	if len(help) == 0 {
		help = options.Name
	}
	name := f.subScope(options.Name)
	tags := f.mergeTags(options.Tags)
	labelNames := f.tagNames(tags)
	opts := prometheus.HistogramOpts{
		Name:    name,
		Help:    help,
		Buckets: asFloatBuckets(options.Buckets),
	}
	hv := f.cache.getOrMakeHistogramVec(opts, labelNames)
	return &timer{
		histogram: hv.WithLabelValues(f.tagsAsLabelValues(labelNames, tags)...),
	}
}
529453
func NewTimer() *Timer {
	return &Timer{t: time.NewTimer(time.Duration(math.MaxInt64))}
}
501855
func (f *Factory) Timer(options metrics.TimerOptions) metrics.Timer {
	timer := &timer{
		timers: make([]metrics.Timer, len(f.factories)),
	}
	for i, factory := range f.factories {
		timer.timers[i] = factory.Timer(options)
	}
	return timer
}
1175989
func (t *SessionTimers) StopAll() {
	t.Lock()
	defer t.Unlock()
	for _, tm := range t.m {
		tm.Stop()
	}
	t.m = make(map[string]*time.Timer)
}
617855
func (c *C) StopTimer() {
	if c.timerOn {
		c.duration += time.Now().Sub(c.start)
		c.timerOn = false
		runtime.ReadMemStats(&memStats)
		c.netAllocs += memStats.Mallocs - c.startAllocs
		c.netBytes += memStats.TotalAlloc - c.startBytes
	}
}
627467
func (r *hostPathDeleter) Delete() error {
	regexp := regexp.MustCompile("/tmp/.+")
	if !regexp.MatchString(r.GetPath()) {
		return fmt.Errorf("host_path deleter only supports /tmp/.+ but received provided %s", r.GetPath())
	}
	return os.RemoveAll(r.GetPath())
}
729766
func (t *timedCache) Delete(key string) error {
	return t.store.Delete(&cacheEntry{
		key: key,
	})
}
429486
func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (*taskAPI.DeleteResponse, error) {
	return nil, errdefs.ErrNotImplemented
}
255139
func (rl *MemoryReplayLog) Delete(hash *HashPrefix) error {
	if rl.entries == nil || rl.batches == nil {
		return errReplayLogNotStarted
	}

	delete(rl.entries, *hash)
	return nil
}
398669
func (r *ResetTimer) Close() {
	r.lock.Lock()
	defer r.lock.Unlock()
	state := atomic.LoadInt64(&r.started)

	if state > 0 {
		defer func() {
			r.kill = nil
			r.reset = nil
		}()
		close(r.kill)
		close(r.reset)
	}

	atomic.StoreInt64(&r.state, 0)
	atomic.StoreInt64(&r.started, 0)
}
607568
func (t *Timer) Reset(d time.Duration) bool {
	if t.timer != nil {
		return t.timer.Reset(d)
	}

	t.next = t.mock.now.Add(d)
	registered := !t.stopped
	if t.stopped {
		t.mock.mu.Lock()
		t.mock.timers = append(t.mock.timers, (*internalTimer)(t))
		t.mock.mu.Unlock()
	}
	t.stopped = false
	return registered
}
822476
func RemoveToLastF(Len int, Less func(i, j int) bool, Swap func(i, j int), i int) {
	n := Len - 1
	if n != i {
		Swap(i, n)
		heapDown(n, Less, Swap, i)
		heapUp(Less, Swap, i)
	}
}
459692
func (t *PCPTimer) Reset() error {
	t.mutex.Lock()
	defer t.mutex.Unlock()

	if t.started {
		return errors.New("trying to reset an already started timer")
	}

	return t.set(float64(0))
}
1088488
func (h *nodeHeartbeater) clearHeartbeatTimer(id string) error {
	h.heartbeatTimersLock.Lock()
	defer h.heartbeatTimersLock.Unlock()

	if timer, ok := h.heartbeatTimers[id]; ok {
		timer.Stop()
		delete(h.heartbeatTimers, id)
	}
	return nil
}
76891
func (d *MutexDatastore) Delete(key ds.Key) (err error) {
	d.Lock()
	defer d.Unlock()
	return d.child.Delete(key)
}