Documentation
¶
Overview ¶
Package threadsafe defines lock interfaces for building reusable, goroutine-safe data structures and helpers without hard-coding a concrete lock type.
It defines two lock interfaces:
- Locker: the write-lock contract (`Lock` and `Unlock`), a defined type sharing the method set of sync.Locker.
- RLocker: the read-lock contract (`RLock` and `RUnlock`) used by read/write synchronization patterns.
These interfaces are embedded or referenced by concurrent containers and utility types used across multiple goroutines.
Usage ¶
See the examples in:
- github.com/tecnickcom/nurago/pkg/threadsafe/tsmap
- github.com/tecnickcom/nurago/pkg/threadsafe/tsslice
Read helpers in dependent packages accept RLocker, which a plain sync.Mutex does not satisfy (it has no `RLock`/`RUnlock`). This forces callers that need shared read access to supply an sync.RWMutex-like type at compile time, rather than serializing every read behind an exclusive lock. A sync.RWMutex satisfies both Locker and RLocker, so the same lock instance can drive read and write helpers.
These interfaces only describe the locking contract; they do not enforce it. All access to the protected data must funnel through the helper functions using the same lock instance, otherwise concurrent reads and writes are not safe.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package tsmap provides lock-aware generic helpers for operating on Go maps shared across multiple goroutines, keeping synchronization explicit at every call site.
|
Package tsmap provides lock-aware generic helpers for operating on Go maps shared across multiple goroutines, keeping synchronization explicit at every call site. |
|
Package tsslice provides lock-aware generic helpers for operating on Go slices shared across multiple goroutines, keeping synchronization explicit around every access.
|
Package tsslice provides lock-aware generic helpers for operating on Go slices shared across multiple goroutines, keeping synchronization explicit around every access. |