github.com/benz9527/xboot@v0.0.0-20240504061247-c23f15593274/timer/options_others.go (about)

     1  //go:build !linux && !windows
     2  // +build !linux,!windows
     3  
     4  package timer
     5  
     6  import (
     7  	"github.com/benz9527/xboot/lib/hrtime"
     8  )
     9  
    10  const (
    11  	SdkDefaultTime TimingWheelTimeSourceEnum = iota
    12  	GoNativeClock
    13  )
    14  
    15  func WithTimingWheelTimeSource(source TimingWheelTimeSourceEnum) TimingWheelsOption {
    16  	return func(opt *xTimingWheelsOption) {
    17  		switch source {
    18  		case GoNativeClock:
    19  			opt.clock = hrtime.GoMonotonicClock
    20  		case SdkDefaultTime:
    21  			fallthrough
    22  		default:
    23  			opt.clock = hrtime.SdkClock
    24  		}
    25  	}
    26  }