Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elijahr/lockfreequeues
Lock-free queue implementations for Nim.
https://github.com/elijahr/lockfreequeues
circular-buffer lock-free mpmc mpsc nim queue ring-buffer spsc
Last synced: 17 days ago
JSON representation
Lock-free queue implementations for Nim.
- Host: GitHub
- URL: https://github.com/elijahr/lockfreequeues
- Owner: elijahr
- License: mit
- Created: 2020-07-03T00:20:00.000Z (over 4 years ago)
- Default Branch: devel
- Last Pushed: 2024-09-29T00:00:30.000Z (about 1 month ago)
- Last Synced: 2024-10-03T12:25:02.514Z (about 1 month ago)
- Topics: circular-buffer, lock-free, mpmc, mpsc, nim, queue, ring-buffer, spsc
- Language: Nim
- Homepage:
- Size: 538 KB
- Stars: 42
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
- awesome-nim - lockfreequeues - Lock-free queue implementations for Nim. (Operating System / IO)
README
[![build](https://github.com/elijahr/lockfreequeues/actions/workflows/build.yml/badge.svg)](https://github.com/elijahr/lockfreequeues/actions/workflows/build.yml)
# lockfreequeues
Lock-free queues for Nim, implemented as ring buffers.
Three implementations are provided:
- [`Sipsic`](https://elijahr.github.io/lockfreequeues/lockfreequeues/sipsic.html) is a single-producer, single-consumer bounded queue. Pushing and popping are wait-free.
- [`Mupsic`](https://elijahr.github.io/lockfreequeues/lockfreequeues/mupsic.html) is a multi-producer, single-consumer bounded queue. Popping is wait-free.
- [`Mupmuc`](https://elijahr.github.io/lockfreequeues/lockfreequeues/mupmuc.html) is a multi-producer, multi-consumer bounded queue.API documentation: https://elijahr.github.io/lockfreequeues
## Installation
```sh
nimble install lockfreequeues
```## Examples
Examples are located in the [examples](https://github.com/elijahr/lockfreequeues/tree/master/examples) directory and can be compiled and run with:
```sh
nimble examples
```## Reference
- Juho Snellman's post ["I've been writing ring buffers wrong all these years"](https://www.snellman.net/blog/archive/2016-12-13-ring-buffers/) ([alt](https://web.archive.org/web/20200530040210/https://www.snellman.net/blog/archive/2016-12-13-ring-buffers/))
- Mamy Ratsimbazafy's [research on SPSC channels](https://github.com/mratsim/weave/blob/master/weave/cross_thread_com/channels_spsc.md#litterature) for weave.
- Henrique F Bucher's post ["Yes, You Have Been Writing SPSC Queues Wrong Your Entire Life"](http://www.vitorian.com/x1/archives/370) ([alt](https://web.archive.org/web/20191225164231/http://www.vitorian.com/x1/archives/370))Many thanks to Mamy Ratsimbazafy for reviewing the initial release and offering suggestions.
## Contributing
- Pull requests and feature requests are welcome!
- Please file any issues you encounter.
- For pull requests, please see the [contribution guidelines](https://github.com/elijahr/lockfreequeues/tree/master/CONTRIBUTING.md).## Running tests
Tests can be run locally with `nimble test`.
CI runs the test suite for both C and C++ targets on:
- Linux `x86_64` and `aarch64`
- macOS `x86_64`The test suite is also run with [LLVM thread sanitization](https://clang.llvm.org/docs/ThreadSanitizer.html) to check for data races.