naco-api/internal/utils/counter.go
2026-08-03 13:23:52 +00:00

23 lines
290 B
Go

package utils
import "sync/atomic"
type Counter struct {
value atomic.Int64
}
func NewCounter() *Counter {
return &Counter{}
}
func (c *Counter) Increment() {
c.value.Add(1)
}
func (c *Counter) Get() int64 {
return c.value.Load()
}
func (c *Counter) Reset() {
c.value.Store(0)
}