Skip to content

Latest commit

 

History

History
11 lines (7 loc) · 760 Bytes

README.md

File metadata and controls

11 lines (7 loc) · 760 Bytes

GoDoc

kmutex

Synchronization primitive that allows locking individual resources by unique ID.

This is not a distributed lock.

See golang.org/x/sync/singleflight if you want to reduce the number of calls to the same resource. Use kmutex if you want only one caller to use a resource at time.

Kubernetes kmutex hashes keys to a fixed set of locks, and is useful if you do not always need a separate lock for each resource. Take a look at the implementation, it is very straight forward.

GO PLAYGROUND EXAMPLE