mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
25
app/stats/counter.go
Normal file
25
app/stats/counter.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
// +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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue