Exemple #1
0
func (alarm *GoQuicAlarm) OnAlarm() {
	if now := int64(C.clock_now(alarm.clock)); now < alarm.deadline {
		// This should be very rarely occrued. Otherwise this could be performance bottleneck.
		fmt.Println(now, time.Now().UnixNano()/1000000, alarm.wrapper, alarm.deadline, "Warning: Timer not adjustted")
		alarm.SetImpl()
		return
	}

	// There can be race condition between QuicAlarm destruction and OnAlarm callback. So this check is needed
	if alarm.isCanceled {
		return
	}

	C.go_quic_alarm_fire(alarm.wrapper)
}
Exemple #2
0
func (alarm *GoQuicAlarm) Now() int64 {
	return int64(C.clock_now(alarm.clock))
}