Code Monkey home page Code Monkey logo

queueworld's Introduction

Queue World

A light-weight C++ toolkit for building concurrent, lock-free, message-passing programs.

Queue World is a little collection of light-weight C++ data structures for lock-free multi-threaded programming. The focus is on providing simple primitives using well-known algorithms. Queue World makes heavy use of endogenous linking (links embedded in client structures). This avoids allocator overhead. In addition to concurrent queues, a variety of non-re-entrant endogenous linked-lists are also provided.

Concurrent data structures

QwMpmcPopAllLifoStack -- a multiple-producer multiple-consumer LIFO stack that supports push() and pop_all() operations, but not pop().

QwMpscFifoQueue -- a multiple-producer single-consumer FIFO stack. Useful for a server thread that receives requests sent from many client threads.

QwSpscUnorderedResultQueue -- a single-producer single-consumer "relaxed order" queue for returning results from a server thread to a client. Includes a client-side counter for tracking expected vs. received results.

QwNodePool -- a concurrent freelist that allocates and frees fixed-size nodes from a fixed-size node pool. Guarantees cache-line alignment of each node to avoid false sharing.

Single threaded (non-reentrant) data structures

QwSList -- a singly linked list

QwSTailList -- a singly linked "tail list" (supports constant-time insertion at back)

QwList -- a doubly linked list

The single threaded data structures provide an STL-like interface.

Philosophy

Queue World is envisaged as an inter-thread communication library for real-time audio applications, where mutexes are not an option due to the risk of priority inversion. The typical use-cases involve relatively low queue contention. The main goals have been to keep things simple and to provide infrastructure for avoiding priority inversion.

If you're looking for water-tight abstractions you might be in the wrong place. The goal here is simple and efficient implementations, even if that means having a few "pipes on the outside of the building." This is most strongly reflected in the use of endogenous linking.

Implementation Details

For simplicity of implementation, the lock-free data structures are currently built out of variations on the well-known "IBM Freelist" (see ALGORITHMS.txt for details). The main advantage of this approach is that it avoids the need to manage additional link nodes.

In the future we plan to experiment with other algorithms and to evaluate performance. In particular, an MS-queue is desirable for use as an MPMC FIFO.

Queue World uses Mintomic (https://github.com/mintomic) for atomic operations and memory barriers. Queue world does not require the availability of C++11 atomics.

All Queue World classes are provided with unit tests written using Catch (https://github.com/philsquared/Catch).

Licence

Queue World is copyright (c) 2014 Ross Bencina.

Queue World is licensed under The MIT Licence: http://opensource.org/licenses/MIT

queueworld's People

Contributors

rossbencina avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.