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

     1  //go:build linux
     2  // +build linux
     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  	UnixClock
    14  )
    15  
    16  func WithTimingWheelTimeSource(source TimingWheelTimeSourceEnum) TimingWheelsOption {
    17  	return func(opt *xTimingWheelsOption) {
    18  		switch source {
    19  		case GoNativeClock:
    20  			opt.clock = hrtime.GoMonotonicClock
    21  		case UnixClock:
    22  			opt.clock = hrtime.UnixMonotonicClock
    23  		case SdkDefaultTime:
    24  			fallthrough
    25  		default:
    26  			opt.clock = hrtime.SdkClock
    27  		}
    28  	}
    29  }