mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 12:40:11 +00:00
26 lines
433 B
Go
26 lines
433 B
Go
package counter
|
|
|
|
import (
|
|
"sync/atomic"
|
|
|
|
fstats "github.com/xtls/xray-core/features/stats"
|
|
)
|
|
|
|
var _ fstats.Counter = (*XrayTrafficCounter)(nil)
|
|
|
|
type XrayTrafficCounter struct {
|
|
V *atomic.Int64
|
|
}
|
|
|
|
func (c *XrayTrafficCounter) Value() int64 {
|
|
return c.V.Load()
|
|
}
|
|
|
|
func (c *XrayTrafficCounter) Set(newValue int64) int64 {
|
|
return c.V.Swap(newValue)
|
|
}
|
|
|
|
func (c *XrayTrafficCounter) Add(delta int64) int64 {
|
|
return c.V.Add(delta)
|
|
}
|