Skip to main content

All Questions

Tagged with
2 votes
1 answer
56 views

A Simple BlockingQueue implementation in C++

I'm just dusting off my C++ knowledge in area of multithreading. I started with implementing a producer-consumer pattern inspired by https://jenkov.com/tutorials/java-util-concurrent/blockingqueue....
Matt Black's user avatar
2 votes
1 answer
94 views

Multi Threaded File Processing C++

Background: The program reads 1000000 lines in the file. Every four line will be parsed into an object in a vector. If it has 2 objects with the same name, it will drop 1 object and increment one of ...
SummerGram's user avatar
2 votes
1 answer
839 views

Efficient parallelization of small tasks

Problem statement: Consider a scenario where a vector of very small tasks, each encapsulated within a class 'Task' with a thread-safe method Task::process(), needs to be efficiently processed in ...
Shakti Malik's user avatar
4 votes
4 answers
2k views

Yet another shared_ptr implementation for learning purposes

C++ shared_ptr implemented as a coding practice and learning purposes. It uses std::shared_ptr interface. Basic tests are included (using single header Catch 2) Some methods are omitted to keep the ...
Tomas Tintera's user avatar
4 votes
1 answer
126 views

Packet generation and consumption

I have the following simplification of a program which consists of 2 threads. One thread pushes packets to the back of a deque while another waits for user input before performing a "heavy" ...
Bula's user avatar
  • 369
6 votes
1 answer
908 views

Simple, fool-proof pattern to execute tasks in parallel

Assume I have a type task_info that stores the task-specific data needed to execute the task. A std::vector of those is built ...
Bolpat's user avatar
  • 233
3 votes
2 answers
292 views

atomic spinlock mutex class

This here is the follow-up to this question. I was recommended to implement a Lockable type (similar to std::mutex) that can work with ...
digito_evo's user avatar
2 votes
1 answer
186 views

C++20 simple RwSeqLock

I recently discovered the atomic wait/notify mechanism in C++20 and wrote this readers-writer lock in the style of Linux kernel Seqlock. Writes have to be inside a lock/unlock, while reads are ...
MDH's user avatar
  • 23
2 votes
1 answer
132 views

Thread Pool Class

I have a thread_pool class, that mimics std::thread. (I would have liked std to have a pool, but alas that is not the case.) thread_pool.h ...
rioki's user avatar
  • 462
4 votes
1 answer
841 views

Thread Safe Queue

I have a thread safe queue in my library c9y. It is generally used as a task queue in the task_pool class, but in can be used for any producer / consumer problem. queue.h ...
rioki's user avatar
  • 462
2 votes
1 answer
477 views

Sender/Receiver threads using std::unique_lock and std::condition_variable

The code below is a sender/receiver setup in C++ where the sender is in one thread, the receiver is in another, and the data being sent/received is "shared" (global). The code uses the ...
tarstevs's user avatar
2 votes
1 answer
2k views

C++20 Multi-queue Thread Pool with Work Stealing

This is a follow up to my previous post which also follows up on my first post regarding my thread pool implementation. I have since made some further changes and attempted to improve performance with ...
Developer Paul's user avatar
3 votes
1 answer
274 views

Lock-free, thread-safe trie container

This is a Trie data structure for mapping strings to integers or pointers in O(n) time. Based on the idea that we never delete anything from the container, we can perform concurrent read/write ...
CaptainCodeman's user avatar
5 votes
2 answers
2k views

C++20 Single Queue Thread Pool

This is a follow up to my previous post. I've made a number of improvements to the thread pool and corrected some bugs as well. The most up to date version of the code is available on my Github. I ...
Developer Paul's user avatar
2 votes
1 answer
3k views

C++14 Lock-free Multi-producer, Multi-Consumer Queue

Introduction This is a follow-up to a previous question of mine, where I presented another queue of the same type to get some feedback on it. Some people pointed out some fundamental errors I had ...
Primrose's user avatar

15 30 50 per page
1
2 3 4 5