All checks were successful
CI/CD Go Verification / build_and_test (push) Successful in 1m44s
23 lines
290 B
Go
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)
|
|
}
|