Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 2 months ago
JSON representation

Lock-free queue implementations for Nim.

Awesome Lists containing this project

README

        

![build](https://github.com/elijahr/lockfreequeues/workflows/build/badge.svg) ![lint](https://github.com/elijahr/lockfreequeues/workflows/lint/badge.svg) ![build-docs](https://github.com/elijahr/lockfreequeues/workflows/build-docs/badge.svg) [![Join the chat at https://gitter.im/lockfreequeues/community](https://badges.gitter.im/lockfreequeues/community.svg)](https://gitter.im/lockfreequeues/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

# 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.

### Linting

This project uses [lintball](https://github.com/elijahr/lintball) to auto-format code. Please ensure your changeset passes linting. Enable the githooks with:

```sh
git config --local core.hooksPath .githooks
```