Giter Site home page Giter Site logo

gt-flexr / flexr_shmq Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 20 KB

A simple and lightweight shared memory queue with some useful features

License: MIT License

CMake 9.54% C++ 84.19% Shell 6.27%
interprocess-communication interprocess-communication-library shared-memory-communication shared-memory-queue

flexr_shmq's Introduction

FleXR_ShmQ

This is a lightweight shared memory queue library on Linux (tested on Ubuntu 18.04,20.04,22.04). I originally write FleXR_ShmQ for my main project, FleXR, but this can be useful for other usage.

Install & Test

git clone https://github.com/gt-flexr/FleXR_ShmQ.git
cd FleXR_ShmQ && mkdir build && cd build
cmake .. && make -j$(nproc)
sudo make install

./test.sh

Features

Other than the basic queue functionalities, there are additional and useful functionalities.

Type free & Queue Size

| FlexrShmQueue | FlexrElemMeta + Elem Data | FlexrElemMeta + Elem Data | FlexrElemMeta + Elem Data | ... |

Each data of queue element is treated as byte array. As shown above, each element has meta data for the actual data of the queue element; the initial FlexrShmQueue is the meta data about the queue itself (rear, front, current # of elemes, and lock). You can set the maximum number of queue elements.

Communication Semantics: Blocking and Non-blocking

When the API is called, blocking/non-blocking can be set for enqueuing/dequeuing. With blocking semantics, the en/dequeue wait for the receiving end's corresponding operations.

For instance, when enqueuing with blocking, the sending process waits for the receiving process to dequeue. When dequeuing with blocking, the receiving process waits for the sending process to enqueue. With non-blocking, it checkes the queue memory for figuring out the queue element existence. If no element in the queue, it returns nothing.

Partial Enqueue/Dequeue

When necessary, you can put multiple variables into a queue element with total size. Then, the receiving end can dequeue a element in multiple times (partial dequeue). You can serialize the multiple data via boost or other serialization methods, but sometimes it can overkill; you need to add additional methods to your project as a dependency. If you want to do it in a quick way, use this feature.

flexr_shmq's People

Contributors

jheo4 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.