Giter Site home page Giter Site logo

alihaskar / atomic-queue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arossoshynskyy/atomic-queue

0.0 0.0 0.0 27 KB

A lock-free, thread-safe, multi-producer/multi-consumer queue based on the LMAX Disruptor.

License: MIT License

Python 100.00%

atomic-queue's Introduction

atomic-queue

A thread-safe, lock-free queue implementation based on the LMAX Disruptor, with crititcal parts written in C++.

This queue supports multiple producers and consumers. Producers are responsible for managing their own threads, while consumer threads are managed by the queue and are required to implement the EventHandler interface.

Example

Initialise an atomic queue instance with the buffer capacity and a wait strategy. The buffer capacity must be a power of 2 integer.

from atomicqueue import AtomicQueue, BUSY_SPIN_WAIT_STRATEGY

queue = AtomicQueue(256, wait_strategy=BUSY_SPIN_WAIT_STRATEGY)

Define how the events will be consumed. In the example below event handler "h_one" and "h_two" can overrun each other but can not overrun the publishers, while event handler "h_three" can only consume events after "h_one" and "h_two" have finished consuming them.

queue.handle_events_with(NoOpEventHandler("h_one"), NoOpEventHandler("h_two")).then(NoOpEventHandler("h_three"))

Once configured the queue can be started with the following command.

queue.start()

To publish to the queue, simply call publish_event on the queue.

queue.publish_event(event)

Stop the queue by calling stop().

queue.stop()

atomic-queue's People

Contributors

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