Concurrent is a library of lock-free and wait-free algorithms
- amd64 or arm64 CPU architecture
- Go 1.25 or later
To install the concurrent library, run the following command:
go get code.hybscloud.com/concurrentc, p := concurrent.NewQueue[string](256)
message := "Hello, Concurrent!"
err := concurrent.EnqueueWait(p, &message)
if err != nil {
return err
}
result, err := concurrent.DequeueWait(c)
if err != nil {
return err
}
println(*result)c, p := concurrent.NewMPMCQueue[int](256)
i := 100
err := p.Enqueue(&i)
if err != nil {
return err
}
res, err := c.Dequeue()
if err != nil {
return err
}
println(*res)c, p := concurrent.NewMPMCQueueIndirect(256)
index := uintptr(42)
err := p.Enqueue(index)
if err != nil {
return err
}
value, err := c.Dequeue()
if err != nil {
return err
}
println(value)lock := concurrent.SpinLock{} // the zero value is ready to use
lock.Lock()
...
lock.Unlock()sw := concurrent.SpinWait{} // the zero value is ready to use
sw.Once()Implement the sCQ lock-free FIFO queue
- A. Morrison and Y. Afek, "Fast concurrent queues for x86 processors," in Proc. 18th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP), 2013.
- R. Nikolaev, "A scalable, portable, and memory-efficient lock-free FIFO queue," in Proc. 33rd International Symposium on Distributed Computing (DISC), 2019. LIPIcs.
- N. Koval and V. Aksenov, "POSTER: Restricted memory-friendly lock-free bounded queues," in Proc. 25th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP), 2020, pp. 433–434.
- R. Nikolaev and B. Ravindran, "wCQ: A fast wait-free queue with bounded memory usage," arXiv preprint arXiv:2201.02179, Jan. 2022.
- V. Aksenov, N. Koval, P. Kuznetsov, and A. Paramonov, "Memory bounds for concurrent bounded queues," arXiv preprint arXiv:2104.15003v5, Jan. 2024.
- A. Denis and C. Goedefroit, "NBLFQ: A lock-free MPMC queue optimized for low contention," in Proc. 39th IEEE International Parallel and Distributed Processing Symposium (IPDPS), 2025, pp. 962–973.
- Intel Corporation, "Combined Volume Set of Intel 64 and IA-32 Architectures Software Developer’s Manuals."
- Arm Limited, "Arm Architecture Reference Manual for A-profile architecture," DDI 0596, latest revision.
©2023 Hayabusa Cloud Co., Ltd.
#5F Eclat BLDG, 3-6-2 Shibuya, Shibuya City, Tokyo 150-0002, Japan
Released under the MIT license