mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
499 B
26 lines
499 B
4 years ago
|
// +build !confonly
|
||
|
|
||
|
package stats
|
||
|
|
||
|
import "sync/atomic"
|
||
|
|
||
|
// Counter is an implementation of stats.Counter.
|
||
|
type Counter struct {
|
||
|
value int64
|
||
|
}
|
||
|
|
||
|
// Value implements stats.Counter.
|
||
|
func (c *Counter) Value() int64 {
|
||
|
return atomic.LoadInt64(&c.value)
|
||
|
}
|
||
|
|
||
|
// Set implements stats.Counter.
|
||
|
func (c *Counter) Set(newValue int64) int64 {
|
||
|
return atomic.SwapInt64(&c.value, newValue)
|
||
|
}
|
||
|
|
||
|
// Add implements stats.Counter.
|
||
|
func (c *Counter) Add(delta int64) int64 {
|
||
|
return atomic.AddInt64(&c.value, delta)
|
||
|
}
|