Giter VIP home page Giter VIP logo

multi-threaded-queue-service-class's Introduction

multi-threaded-queue-service-class

The multi_threaded_queue_service is a class that operates as a message processing service. It provides the following functionalities:

  1. A service via a thread-safe function (write_queue()) to allow a client/producer to write to its internal FIFO/queue. When the queue is full, it will disallow writing and wait for a signal indicating that it can resume because reader threads have popped messages off of the queue/FIFO.

  2. Built-in internal "consumer/service/reader" threads. The number of these threads is configurable. They are reused after they finish processing an associated message from the queue, thereby eliminating the expense of dynamically creating threads as needed.

  3. Conditional_variable functionality for signaling to and between all pending threads so they know when it is and is not appropriate to attempt their respective queue operations (reads/writes).

  4. A customizable read_queue() thread function to process the message that is read from the queue as required by the application.

Note: The queue currently contains string elements (as messages to process) in this implementation. It is expected that the format of the message will be modified as needed (based on application requirements).

Several STL templates and classes are used to accomplish the aforementioned functionalities, including:

std::vector std::thread read_threads; // vector of the internal read threads

std::atomic execute_threads; // flag telling if we should execute or not

std::queue std::string msg_queue; // queue to write to and read from

std::mutex mtx; // shared mutex, managed by a per thread queue_lock

std::condition_variable check_queue_readiness_cv; // cv for accessing msg_queue

multi-threaded-queue-service-class's People

Contributors

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