Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedClock ¶
type CachedClock struct {
// contains filtered or unexported fields
}
CachedClock provides a fast, low-cost timestamp read for the hot path. It is updated by a background goroutine at a configurable interval (default 10ms for High-performance performance). Hot path reads are atomic loads of an int64 unix-nanoseconds value.
func GetGlobalCachedClock ¶
func GetGlobalCachedClock() *CachedClock
GetGlobalCachedClock returns the singleton cached clock instance.
func NewCachedClock ¶
func NewCachedClock(updateInterval time.Duration) *CachedClock
NewCachedClock creates a CachedClock whose cached timestamp is refreshed by a background goroutine every updateInterval. A non-positive interval defaults to 10ms.
func (*CachedClock) Close ¶
func (cc *CachedClock) Close()
Close stops the background refresh goroutine. It is safe to call multiple times.
func (*CachedClock) GetNsec ¶
func (cc *CachedClock) GetNsec() *atomic.Int64
GetNsec returns a pointer to the atomic cached nanoseconds value.
func (*CachedClock) GetNsecValue ¶
func (cc *CachedClock) GetNsecValue() int64
GetNsecValue returns the cached nanoseconds value directly (for hot path optimization)
func (*CachedClock) Now ¶
func (cc *CachedClock) Now() time.Time
Now returns the cached time as a time.Time.