// PingPeriod sets the duration for sending websocket pings.
// It should only be used in the constructor - not Goroutine-safe.
337999
func PingPeriod(pingPeriod time.Duration) func(*wsConnection) {
	return func(wsc *wsConnection) {
		wsc.pingPeriod = pingPeriod
	}
}
717212
func (c *Conn) PingMonitor(id string) (string, error) {
	c_id := C.CString(id)
	defer C.free(unsafe.Pointer(c_id))

	var strlen C.size_t
	var strout *C.char

	ret := C.rados_ping_monitor(c.cluster, c_id, &strout, &strlen)
	defer C.rados_buffer_free(strout)

	if ret == 0 {
		reply := C.GoStringN(strout, (C.int)(strlen))
		return reply, nil
	} else {
		return "", RadosError(int(ret))
	}
}
812779
func (n *Node) pinging() bool {
	n.state.RLock()
	pinging := n.state.pinging
	n.state.RUnlock()

	return pinging
}
786060
func (s *BudgetedAndActualAmounts) SetTimePeriod(v *TimePeriod) *BudgetedAndActualAmounts {
	s.TimePeriod = v
	return s
}
1299585
func (c *Client) pingRoutine() {
	ticker := time.NewTicker(time.Second * 5)
	defer ticker.Stop()

	var timestamp uint64
	var tcpPingAvg float32
	var tcpPingVar float32
	packet := MumbleProto.Ping{
		Timestamp:  &timestamp,
		TcpPackets: &c.tcpPacketsReceived,
		TcpPingAvg: &tcpPingAvg,
		TcpPingVar: &tcpPingVar,
	}

	t := time.Now()
	for {
		timestamp = uint64(t.UnixNano())
		tcpPingAvg = math.Float32frombits(atomic.LoadUint32(&c.tcpPingAvg))
		tcpPingVar = math.Float32frombits(atomic.LoadUint32(&c.tcpPingVar))
		c.Conn.WriteProto(&packet)

		select {
		case <-c.end:
			return
		case t = <-ticker.C:
			// continue to top of loop
		}
	}
}
403425
func (s *Server) schedulePeriodic(stopCh chan struct{}) {
	evalGC := time.NewTicker(s.config.EvalGCInterval)
	defer evalGC.Stop()
	nodeGC := time.NewTicker(s.config.NodeGCInterval)
	defer nodeGC.Stop()
	jobGC := time.NewTicker(s.config.JobGCInterval)
	defer jobGC.Stop()
	deploymentGC := time.NewTicker(s.config.DeploymentGCInterval)
	defer deploymentGC.Stop()

	// getLatest grabs the latest index from the state store. It returns true if
	// the index was retrieved successfully.
	getLatest := func() (uint64, bool) {
		snapshotIndex, err := s.fsm.State().LatestIndex()
		if err != nil {
			s.logger.Error("failed to determine state store's index", "error", err)
			return 0, false
		}

		return snapshotIndex, true
	}

	for {

		select {
		case <-evalGC.C:
			if index, ok := getLatest(); ok {
				s.evalBroker.Enqueue(s.coreJobEval(structs.CoreJobEvalGC, index))
			}
		case <-nodeGC.C:
			if index, ok := getLatest(); ok {
				s.evalBroker.Enqueue(s.coreJobEval(structs.CoreJobNodeGC, index))
			}
		case <-jobGC.C:
			if index, ok := getLatest(); ok {
				s.evalBroker.Enqueue(s.coreJobEval(structs.CoreJobJobGC, index))
			}
		case <-deploymentGC.C:
			if index, ok := getLatest(); ok {
				s.evalBroker.Enqueue(s.coreJobEval(structs.CoreJobDeploymentGC, index))
			}
		case <-stopCh:
			return
		}
	}
}
86205
func ParsePeriodic(start, duration string) (*Periodic, error) {
	var err error

	pc := &Periodic{}

	if pc.start, err = parseStart(start); err != nil {
		return nil, fmt.Errorf("unable to parse start: %v", err)
	}

	if pc.duration, err = time.ParseDuration(duration); err != nil {
		return nil, fmt.Errorf("unable to parse duration: %v", err)
	}

	if pc.duration < time.Duration(0) {
		return nil, fmt.Errorf("duration cannot be negative")
	}

	// check that the duration of the window does not exceed the period.
	if (pc.start.dayOfWeek == -1 && pc.duration >= 24*time.Hour) || pc.duration >= 7*24*time.Hour {
		return nil, fmt.Errorf("duration cannot exceed period")
	}

	return pc, nil
}
489043
func (s *GetReservationUtilizationInput) SetTimePeriod(v *DateInterval) *GetReservationUtilizationInput {
	s.TimePeriod = v
	return s
}
1080526
func Ping(host string, timeout time.Duration) bool {
	return (&instance{server: host}).ping(timeout)
}
756914
func (p *peer) pingHandler() {
	defer p.wg.Done()

	pingTicker := time.NewTicker(pingInterval)
	defer pingTicker.Stop()

	// TODO(roasbeef): make dynamic in order to create fake cover traffic
	const numPingBytes = 16

out:
	for {
		select {
		case <-pingTicker.C:
			p.queueMsg(lnwire.NewPing(numPingBytes), nil)
		case <-p.quit:
			break out
		}
	}
}
1220630
func (p *DefaultWordTokenizer) TypeNoSentPeriod(t *Token) string {
	if p == nil {
		return ""
	}

	if t.SentBreak {
		return p.TypeNoPeriod(t)
	}

	return p.Type(t)
}
1188115
func (p *Process) pingWait(addr string, timeout time.Duration) error {
	// Default to local process if addr not specified.
	if addr == "" {
		addr = fmt.Sprintf("localhost:%s", p.Port)
	}

	logger := p.Logger.New("fn", "pingWait", "addr", addr, "timeout", timeout)

	ticker := time.NewTicker(checkInterval)
	defer ticker.Stop()

	timer := time.NewTimer(timeout)
	defer timer.Stop()

	for {
		select {
		case <-timer.C:
			return ErrTimeout
		case <-ticker.C:
		}

		if err := p.ping(addr, timeout); err != nil {
			logger.Error("ping error", "err", err)
			continue
		}

		return nil
	}
}
22132
func (p *PWMPin) SetPeriod(period uint32) (err error) {
	_, err = p.write(p.pwmPeriodPath(), []byte(fmt.Sprintf("%v", period)))
	return
}
1207812
func (module *BBPWMModule) SetPeriod(pin Pin, ns int64) error {
	openPin := module.openPins[pin]
	if openPin == nil {
		return fmt.Errorf("PWM pin is being written but is not enabled. Have you called EnablePin?")
	}

	return openPin.setPeriod(ns)
}
799872
func (c Calendar) formatDateTimeComponentPeriod(datetime time.Time, length int) (string, error) {
	hour := datetime.Hour()

	switch length {
	case datetimeFormatLength1Plus:
		return c.formatDateTimeComponentPeriodWide(hour), nil
	case datetimeFormatLengthAbbreviated:
		return c.formatDateTimeComponentPeriodAbbreviated(hour), nil
	case datetimeFormatLengthWide:
		return c.formatDateTimeComponentPeriodWide(hour), nil
	case datetimeFormatLengthNarrow:
		return c.formatDateTimeComponentPeriodNarrow(hour), nil
	}

	return "", fmt.Errorf("unsupported day-period: %d", length)
}
218099
func (s *GetInstanceMetricDataInput) SetPeriod(v int64) *GetInstanceMetricDataInput {
	s.Period = &v
	return s
}
379107
func (s *ForecastResult) SetTimePeriod(v *DateInterval) *ForecastResult {
	s.TimePeriod = v
	return s
}