// If the local clock is within a reasonable offset of the server's
// clock, we'll get 0.  Otherwise, we set the skew accordingly. Safe
// to set this every time.
978183
func (a *InternalAPIEngine) updateCriticalClockSkewWarning(resp *http.Response) {

	g := a.G()
	g.oodiMu.RLock()
	criticalClockSkew := int64(computeCriticalClockSkew(a.G(), resp.Header.Get("Date")))
	needUpdate := (criticalClockSkew != a.G().outOfDateInfo.CriticalClockSkew)
	g.oodiMu.RUnlock()

	if needUpdate {
		g.oodiMu.Lock()
		g.outOfDateInfo.CriticalClockSkew = criticalClockSkew
		g.oodiMu.Unlock()
	}
}
670261
func (m *medianTime) Offset() time.Duration {
	m.mtx.Lock()
	defer m.mtx.Unlock()

	return time.Duration(m.offsetSecs) * time.Second
}
465722
func (c *Clock) Tick() {
	currStamp := theTimer.Now()

	c.counter++

	c.deltaStamp = currStamp - c.frameStamp
	c.frameStamp = currStamp

	c.elapsStamp += c.deltaStamp
	if secondsInNano <= c.elapsStamp {
		c.elapsStamp %= secondsInNano
		c.perSecond = c.counter
		c.counter = 0
	}
}
60764
func storeVariableValueLength(dst []byte, offset, value ValueLength, reverse bool) {
	vpackAssert(value > 0)

	idx := offset
	if reverse {
		for value >= 0x80 {
			dst[idx] = byte(value | 0x80)
			idx--
			value >>= 7
		}
		dst[idx] = byte(value & 0x7f)
	} else {
		for value >= 0x80 {
			dst[idx] = byte(value | 0x80)
			idx++
			value >>= 7
		}
		dst[idx] = byte(value & 0x7f)
	}
}
378500
func (a *DateHistogramAggregation) Offset(offset string) *DateHistogramAggregation {
	a.offset = offset
	return a
}
940379
func (s *SyncState) SetLocalValue(addr addrs.AbsLocalValue, value cty.Value) {
	s.lock.Lock()
	defer s.lock.Unlock()

	ms := s.state.EnsureModule(addr.Module)
	ms.SetLocalValue(addr.LocalValue.Name, value)
}
1187736
func (a *StandardEWMA) Tick() {
	count := atomic.LoadInt64(&a.uncounted)
	atomic.AddInt64(&a.uncounted, -count)
	instantRate := float64(count) / float64(5e9)
	a.mutex.Lock()
	defer a.mutex.Unlock()
	if a.init {
		a.rate += a.alpha * (instantRate - a.rate)
	} else {
		a.init = true
		a.rate = instantRate
	}
}
1239625
func (r *Rotation) CheckAndSetDefaults(clock clockwork.Clock) error {
	switch r.Phase {
	case "", RotationPhaseRollback, RotationPhaseUpdateClients, RotationPhaseUpdateServers:
	default:
		return trace.BadParameter("unsupported phase: %q", r.Phase)
	}
	switch r.Mode {
	case "", RotationModeAuto, RotationModeManual:
	default:
		return trace.BadParameter("unsupported mode: %q", r.Mode)
	}
	switch r.State {
	case "":
		r.State = RotationStateStandby
	case RotationStateStandby:
	case RotationStateInProgress:
		if r.CurrentID == "" {
			return trace.BadParameter("set 'current_id' parameter for in progress rotation")
		}
		if r.Started.IsZero() {
			return trace.BadParameter("set 'started' parameter for in progress rotation")
		}
	default:
		return trace.BadParameter(
			"unsupported rotation 'state': %q, supported states are: %q, %q",
			r.State, RotationStateStandby, RotationStateInProgress)
	}
	return nil
}
925104
func RollingClock(clock timetools.TimeProvider) rhOptSetter {
	return func(r *RollingHDRHistogram) error {
		r.clock = clock
		return nil
	}
}
298584
func (c *ConfigLocal) SetClock(cl Clock) {
	c.lock.Lock()
	defer c.lock.Unlock()
	c.clock = cl
}
87448
func DaylightSavingsOffset(t time.Time) int {
	_, offset := t.Zone()
	return offset - TimezoneOffsetNoDST(t)
}
506260
func (lr *LockedRand) Float32() (n float32) {
	lr.lk.Lock()
	n = lr.r.Float32()
	lr.lk.Unlock()
	return
}
255473
func (u *Updater) ensureClock() (time.Time, error) {
	coll, closer := u.collection()
	defer closer()

	// Read the existing clock document if it's there, initialising
	// it with a zero time otherwise.
	var doc clockDoc
	if _, err := coll.FindId(clockDocID).Apply(mgo.Change{
		// We can't use $set here, as otherwise we'll
		// overwrite an existing document.
		Update: bson.D{{"$inc", bson.D{{"time", 0}}}},
		Upsert: true,
	}, &doc); err != nil {
		return time.Time{}, errors.Annotate(err, "upserting clock document")
	}
	return doc.time(), nil
}
942378
func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
	switch {
	case -0.5 < julianFraction && julianFraction < 0.5:
		julianFraction += 0.5
	case julianFraction >= 0.5:
		julianDays++
		julianFraction -= 0.5
	case julianFraction <= -0.5:
		julianDays--
		julianFraction += 1.5
	}
	return julianDays, julianFraction
}
245783
func (dt DateTime) Value() (driver.Value, error) {
	year, month, day := dt.Date()
	hour, minute, second := dt.Clock()
	return time.Date(year, month, day, hour, minute, second, 0, time.UTC), nil
}
1273672
func (r *Rand) Float32() float32 {
	// Same rationale as in Float64: we want to preserve the Go 1 value
	// stream except we want to fix it not to return 1.0
	// There is a double rounding going on here, but the argument for
	// mapping 1 to 0 still applies: 0 was underrepresented before,
	// so mapping 1 to 0 doesn't cause too many 0s.
	// This only happens 1/2²⁴ of the time (plus the 1/2⁵³ of the time in Float64).
	f := float32(Float64())
	if f == 1 {
		f = 0
	}
	return f
}
1302276
func (s *Schedule) SetIsLocalTime(v bool) *Schedule {
	s.IsLocalTime = &v
	return s
}