github.com/benz9527/xboot@v0.0.0-20240504061247-c23f15593274/lib/queue/delay_queue_windows.go (about)

     1  //go:build windows
     2  // +build windows
     3  
     4  package queue
     5  
     6  import (
     7  	"github.com/benz9527/xboot/lib/hrtime"
     8  	"github.com/benz9527/xboot/lib/infra"
     9  )
    10  
    11  func (dq *ArrayDelayQueue[E]) PollToChan(nowFn func() int64, C infra.SendOnlyChannel[E]) {
    12  	// Note: The timer resolution is set to 1ms to improve the accuracy of the delay queue.
    13  	// But below implementation is not a good solution.
    14  	dq.exclusion.Lock()
    15  	hrtime.SetTimeResolutionTo1ms()
    16  	defer func() {
    17  		_ = hrtime.ResetTimeResolutionFrom1ms()
    18  		dq.exclusion.Unlock()
    19  	}()
    20  
    21  	dq.poll(nowFn, C)
    22  }