Giter Site home page Giter Site logo

wzit / gdc-circular_queue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dadocolussi/gdc-circular_queue

0.0 2.0 0.0 119 KB

Shared-memory wait-free single-producer/single-consumer circular queue in C11 and C++11

License: Other

Makefile 0.26% C 2.93% C++ 96.81%

gdc-circular_queue's Introduction

gdc-circular_queue is a wait-free multi-threaded circular queue implementation in C and C++. The source code comes with separate C and C++ implementations, as well as a C++ wrapper for the C implementation (if one wishes to use a common C implementation from C++).

The memory synchronization is based on the atomic types introduced in C11 and C++11. gdc-circular_queue uses POSIX shared memory for the queue data. This makes it possible to use gdc-circular-queue for multi-process applications on some CPU architectures (check your compiler and CPU architecture).

gdc-circular_queue has been tested on Linux using GCC 5.0 and on Mac OS X using clang 7.0.

// Include the .hpp file to use the C++ implementation
#include "gdc_circular_queue_factory.hpp"

// To create a new queue
gdc::circular_queue_factory<char> factory(1000 * 1024);
gdc::circular_queue<char>& queue = factory.get();

// To put data in the queue
std::string s("Hello World!");
queue.push(s.c_str(), s.length());

// To get data from the queue
auto nbytes = queue.available();
auto data = queue.peek();
std::string hello(data, nbytes);

 // Prints Hello World!
std::cout << hello << std::endl;

gdc-circular_queue's People

Contributors

dadocolussi avatar

Watchers

James Cloos 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.