mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-09-02 06:31:44 +00:00
feat(wip): udp rework server side
This commit is contained in:
24
core/internal/utils/atomic.go
Normal file
24
core/internal/utils/atomic.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AtomicTime struct {
|
||||
v atomic.Value
|
||||
}
|
||||
|
||||
func NewAtomicTime(t time.Time) *AtomicTime {
|
||||
a := &AtomicTime{}
|
||||
a.Set(t)
|
||||
return a
|
||||
}
|
||||
|
||||
func (t *AtomicTime) Set(new time.Time) {
|
||||
t.v.Store(new)
|
||||
}
|
||||
|
||||
func (t *AtomicTime) Get() time.Time {
|
||||
return t.v.Load().(time.Time)
|
||||
}
|
Reference in New Issue
Block a user