Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bardiparsi/blockqueue
The BlockQueue pattern is a thread-safe queue implementation that allows multiple threads to push and pop elements concurrently. It provides synchronized access to the underlying queue, ensuring that no data race occurs between threads.
https://github.com/bardiparsi/blockqueue
containers cpp cpp20 generic-programming multi-thread multi-threaded multi-threading multi-threads multiprocessing multithread multithreaded multithreading parallel-computing parallel-programming queue queues thread threading
Last synced: about 2 months ago
JSON representation
The BlockQueue pattern is a thread-safe queue implementation that allows multiple threads to push and pop elements concurrently. It provides synchronized access to the underlying queue, ensuring that no data race occurs between threads.
- Host: GitHub
- URL: https://github.com/bardiparsi/blockqueue
- Owner: BardiParsi
- License: gpl-3.0
- Created: 2024-04-26T23:39:14.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-04-27T00:12:59.000Z (8 months ago)
- Last Synced: 2024-04-27T00:34:42.027Z (8 months ago)
- Topics: containers, cpp, cpp20, generic-programming, multi-thread, multi-threaded, multi-threading, multi-threads, multiprocessing, multithread, multithreaded, multithreading, parallel-computing, parallel-programming, queue, queues, thread, threading
- Language: C++
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Block Queue Pattern
The BlockQueue pattern is a thread-safe queue implementation designed for concurrent multi-threaded environments. It ensures synchronized access to the underlying queue, preventing data races and ensuring thread safety. This implementation allows multiple threads to push and pop elements from the queue concurrently.
## Features
- **Thread Safety:** Utilizes mutex and condition variables to ensure safe concurrent access.
- **Blocking Operations:** Supports blocking push and pop operations, ensuring that threads wait when the queue is full or empty.
- **Dynamic Size:** Allows the specification of a maximum size for the queue, providing flexibility in resource utilization.
- **Simple Integration:** Easy-to-use interface for integrating into multi-threaded applications.# Implementation
BlockQueue.h: Header file containing the implementation of the BlockQueue pattern.
Logger.h and Logger.cpp: Implementation of a simple logging utility for console output.# Dependencies
C++20 or later
# License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
## Usage
```cpp
#include "BlockQueue.h"// Example usage
BlockQueue queue(10); // Create a queue with a maximum size of 10// Push elements into the queue
queue.push(10);
queue.push(20);// Pop elements from the queue
int item = queue.front();
queue.pop();