Repository navigation
π Release notes:
Say hello to waitinline β a fair, context-aware locking mechanism for your Go routines! π
This v1.0.0 release brings you:
β¨ Features:
- π§Ύ FIFO Locking: All lock requests are served in the order they arrived. No line-cutting allowed!
- β±οΈ Context Support: Cancel lock attempts with context timeouts or cancellations β perfect for graceful shutdowns.
- π§ Fair Concurrency: Ideal for use cases where ordering matters (task queues, sequential jobs, fairness guarantees).
- π Drop-in simplicity: Just import and call
Lock(ctx)β get aUnlock()back. Done.
π Why not just sync.Mutex?
Great question! Unlike sync.Mutex, which doesn't guarantee order or cancelability, waitinline:
- βοΈ Guarantees FIFO fairness
- β Doesnβt block forever if your context is cancelled
- π‘ Makes concurrency more predictable in event queues, job workers, rate-limited APIs, and more
π¦ Example:
l := waitinline.New(10)
defer l.Close()
handler, err := l.Lock(context.Background())
if err != nil {
log.Fatal(err)
}
defer handler.Unlock()
// safely access your shared resourceβ€οΈ Contributing
See something off? Have a better idea for naming or implementation? Open an issue, fork the repo, and submit a PR!
Letβs build cool stuff together. π«