Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter represents a thread-safe counter. This structure provides a simple counter that can be safely incremented or decremented in a concurrent environment using atomic operations.
func NewCounter ¶
func NewCounter() *Counter
NewCounter initializes and returns a new instance of Counter. This function creates a Counter instance with the initial count set to zero.
Returns: - *Counter: A pointer to the newly created Counter instance.
func (*Counter) Decrement ¶
Decrement safely decrements the counter by one. This method uses atomic operations to ensure that the decrement operation is thread-safe,
func (*Counter) Increment ¶
Increment safely increments the counter by one. This method uses atomic operations to ensure that the increment operation is thread-safe, preventing race conditions in a concurrent environment.
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration measures the elapsed time from a starting point. This structure allows for the recording of elapsed time in a thread-safe manner using atomic operations for the start time.
func NewDuration ¶
func NewDuration() *Duration
NewDuration initializes and returns a new instance of Duration. It sets the start time to the current time at the moment of creation.
Returns: - *Duration: A pointer to the newly created Duration instance.