// suspicionTimeout computes the timeout that should be used when
// a node is suspected
494263
func suspicionTimeout(suspicionMult, n int, interval time.Duration) time.Duration {
	nodeScale := math.Max(1.0, math.Log10(math.Max(1.0, float64(n))))
	// multiply by 1000 to keep some precision because time.Duration is an int64 type
	timeout := time.Duration(suspicionMult) * time.Duration(nodeScale*1000) * interval / 1000
	return timeout
}
852131
func (p *BasePolicy) socketTimeout() time.Duration {
	if p.TotalTimeout == 0 && p.SocketTimeout == 0 {
		return 0
	} else if p.TotalTimeout > 0 && p.SocketTimeout == 0 {
		return p.TotalTimeout
	} else if p.TotalTimeout == 0 && p.SocketTimeout > 0 {
		return p.SocketTimeout
	} else if p.TotalTimeout > 0 && p.SocketTimeout > 0 {
		if p.SocketTimeout < p.TotalTimeout {
			return p.SocketTimeout
		}
	}
	return p.TotalTimeout
}
1353666
func OptionDetectIPTimeout(timeout time.Duration) Option {
	return func(d *dcosInfo) error {
		if timeout <= 0 {
			return ErrEmptyParam
		}

		d.detectIPTimeout = timeout
		return nil
	}
}
1188177
func (p *Plugin) Timeout() time.Duration {
	p.mu.RLock()
	t := p.timeout
	p.mu.RUnlock()
	return t
}
74977
func (nm *NamedMutex) TryLockTimeout(name string, timeout time.Duration) bool {
	nm.localMutex.Lock()
	mc, ok := nm.mutexMap[name]
	if !ok {
		mc = make(chan struct{}, 1)
		nm.mutexMap[name] = mc
	}
	nm.localMutex.Unlock()
	select {
	case mc <- struct{}{}:
		return true
	case <-time.After(timeout):
		return false
	}
}
860722
func (s *DeleteByQueryService) SearchTimeout(searchTimeout string) *DeleteByQueryService {
	s.searchTimeout = searchTimeout
	return s
}
695523
func (s *Service) stopTimeout(timeout int) int {
	DEFAULTTIMEOUT := 10
	if timeout != 0 {
		return timeout
	}
	configTimeout := utils.DurationStrToSecondsInt(s.Config().StopGracePeriod)
	if configTimeout != nil {
		return *configTimeout
	}
	return DEFAULTTIMEOUT
}
163908
func (s *IndicesRolloverService) Timeout(timeout string) *IndicesRolloverService {
	s.timeout = timeout
	return s
}
1030112
func (cv *CondTimed) WaitRelTimeout(when time.Duration) bool {
	timer := time.AfterFunc(when, func() {
		cv.L.Lock()
		cv.Broadcast()
		cv.L.Unlock()
	})
	cv.Wait()
	return timer.Stop()
}
895721
func (s *OpenIndexService) Timeout(timeout string) *OpenIndexService {
	s.timeout = timeout
	return s
}
558850
func Timeout(d time.Duration) ConfigOpt {
	return func(c *Config) {
		c.transport.ResponseHeaderTimeout = d
		c.transport.TLSHandshakeTimeout = d
		c.dialer.Timeout = d
	}
}
1020727
func (h *HostRegistryListener) getTimeout() time.Duration {
	logger := plog.WithField("poolid", h.poolid)

	var p PoolNode
	if err := h.conn.Get("/pools/"+h.poolid, &p); err != nil {
		logger.WithError(err).Warn("Could not look up resource pool for connection timeout")
		return 0
	}

	return p.GetConnectionTimeout()
}
233057
func (c *Client) TellWithTimeout(method string, timeout time.Duration, args ...interface{}) (result *dnode.Partial, err error) {
	response := <-c.GoWithTimeout(method, timeout, args...)
	return response.Result, response.Err
}
999366
func (s *IndicesPutTemplateService) Timeout(timeout string) *IndicesPutTemplateService {
	s.timeout = timeout
	return s
}
1014928
func (s *IndicesFreezeService) Timeout(timeout string) *IndicesFreezeService {
	s.timeout = timeout
	return s
}
594574
func DeleteTimeout(timeout int64) DeleteOption {
	return func(opts *options) {
		opts.uninstallReq.Timeout = timeout
	}
}
1029619
func (s *DeleteScriptService) Timeout(timeout string) *DeleteScriptService {
	s.timeout = timeout
	return s
}