⬆️ version bump to v4.5

- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5"
- Update version.txt from 4.29 → .30
(automated by Makefile)
This commit is contained in:
Eric Coissac
2026-04-07 08:36:50 +02:00
parent 670edc1958
commit 8c7017a99d
392 changed files with 18875 additions and 141 deletions
+25
View File
@@ -0,0 +1,25 @@
# `obiutils.Counter`: Thread-Safe Atomic Counter
A minimal, thread-safe counter implementation in Go.
## Features
- **Atomic increment/decrement**: `Inc()` and `Dec()` modify the internal counter atomically using a mutex.
- **Current value retrieval**: `Value()` safely returns the current count without modifying it.
- **Initial value support**: Constructor accepts an optional initial integer (defaults to `0`).
- **Closure-based API**: Encapsulates state and synchronization behind clean, functional methods.
- **No external dependencies**: Uses only the standard library (`sync`).
## Usage Example
```go
counter := obiutils.NewCounter(10) // start at 10
fmt.Println(counter.Inc()) // → 11
fmt.Println(counter.Dec()) // → 10
fmt.Println(counter.Value()) // → 10 (unchanged)
```
## Thread Safety
All operations are protected by a `sync.Mutex`, ensuring correctness in concurrent environments.
## Design Notes
- Immutable interface: methods return updated values, not pointers.
- No reset method provided—intentionally minimal and focused on core counting semantics.