mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-08 00:05:46 -04:00
Introduce Counter.Reset()
This commit is contained in:
parent
8a03745273
commit
b067ed2147
1 changed files with 5 additions and 0 deletions
|
|
@ -15,6 +15,11 @@ func (c *Counter) Inc() {
|
|||
c.Add(1)
|
||||
}
|
||||
|
||||
// Reset resets the counter to 0 and returns its previous value.
|
||||
func (c *Counter) Reset() uint64 {
|
||||
return atomic.SwapUint64(c.ptr(), 0)
|
||||
}
|
||||
|
||||
// Val returns the counter value.
|
||||
func (c *Counter) Val() uint64 {
|
||||
return atomic.LoadUint64(c.ptr())
|
||||
|
|
|
|||
Loading…
Reference in a new issue