Giter VIP home page Giter VIP logo

disruptor's Introduction

Disruptor

My take on the LMAX Disruptor, with a different API. Existing C++ implementations of the LMAX disruptor relied on virtual interfaces and dispatch methods that copied from Java. This implementation attempts to do things in a more C++ way and provide what I hope to be a simpler interface.

Design

There are 3 primary types that users of the API must be familiar with:

  • ring_buffer<T,Size> is a circular buffer with Power of 2 Size
  • write_cursor tracks a position in the buffer and can follow other read cursors to ensure things don't wrap.
  • shared_write_cursor is a write_cursor that may be used from multiple threads other read cursors to ensure things don't wrap.
  • read_cursor tracks the read position and can follow / block on other cursors (read or write).
  • thread enables posting of functors to be executed by another thread. This class is 30x faster than fc::thread at posting a request between threads and fc::thread already used a lock-free algorithm with 'constant' event posting time.

The concept of the cursors are separated from the data storage. Every cursor should read from one or more sources and write to its own outbut buffer.

Features

  • Progressive-backoff blocking. When one cursor needs to wait on another it starts out with a busy wait, followed by a yield, and ultimately falls back to sleeping wait if the queue is stalled.

  • Batch writing / Reading with 'iterator like' interface. Producers and consumers always work with a 'range' of valid positions. The ring buffer provides the ability to detect 'wraping' and therefore it should be possible to use this as a data queue for a socket that can read/write many slots all at once. Slots could be single bytes and the result would be a very effecient stream-processing library. This manner of operation is not possible with LMAX's API.

Performance

Simple benchmarks indicate that performance of this implementation is better than other known C++ implementations of this pattern.

disruptor's People

Contributors

bytemaster avatar

Stargazers

 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.