All Questions
Tagged with c++ concurrency
65
questions
3
votes
1
answer
62
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....
2
votes
1
answer
97
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 ...
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 ...
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 ...
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" ...
6
votes
1
answer
911
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 ...
3
votes
2
answers
293
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 ...
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 ...
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
...
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
...
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 ...
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 ...
3
votes
1
answer
275
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 ...
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 ...
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 ...
7
votes
3
answers
1k
views
Lock-free multi-producer / multi-consumer queue in C++
I've been working on a lockless multi-producer, multi-consumer queue in an effort to learn as much as I can about concurrency, without the use of mutual exclusion. The queue uses a bounded ring buffer ...
4
votes
1
answer
189
views
Order guaranteed recursive_transform template function implementation with execution policy in C++
This is a follow-up question for A recursive_transform Template Function with Execution Policy, A recursive_transform Template Function Implementation with std::invocable Concept and Execution Policy ...
5
votes
2
answers
4k
views
C++20 Thread Pool
I've implemented a thread pool using C++20. I'm fairly new to concurrently/multi-threaded programming and wanted to work on a project that I could learn from while also getting to know some of the new ...
3
votes
2
answers
459
views
C++11 revised `std::latch` implementation
This question follows up on this question.
After turning the while-loop into a conditional wait using std::condition_variable, I ...
1
vote
1
answer
451
views
Implementation of a latch
As an exercise to learn more about multi-threading and atomic operations work in C++, I decided to implement a latch class in C++11 loosely based off of std::latch ...
5
votes
3
answers
1k
views
Single Producer Single Consumer lockless ring buffer implementation
I am writing a simple ring buffer for my own education. Below is a crack at a strategy described in http://www.cse.cuhk.edu.hk/~pclee/www/pubs/ancs09poster.pdf : Producer and Consumer keep local ...
1
vote
1
answer
123
views
Concurrent dependant routines in a gui application [closed]
The idea is that, in my application I have 5 routines named long_process_1, long_process_2, ...
8
votes
0
answers
404
views
Implementing GSL synchronized_value
Core Guidelines mention a type synchronized_value<T>, which supposedly pairs std::mutex with the internal value. I couldn'...
4
votes
1
answer
987
views
C++ latch implementation
Since std::latch is not in many standard C++ libraries, I tried implementing my own, is it OK from memory ordering perspective or ...
1
vote
1
answer
1k
views
A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17) - Part 2
This post is based on A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17). I am trying to build a Consumer that consumes data from ...
6
votes
3
answers
3k
views
A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17)
EDID: Thank you very much for your feedback. I updated the code and opened a new post for the updated version. See here.
This post is loosely based on A multi-threaded Producer Consumer with C++11.
...
11
votes
3
answers
6k
views
Multi Threaded High Performance txt file parsing
EDIT
A port of Björn's answer to C++ with further improvements at bottom achieving up to 2.4GB/s on the reference machine.
Text file parsing and processing continues to be a common task. Often it's ...
7
votes
1
answer
116
views
Concurrent Queue Adapter
There's lots of code out there for basic adapters of std::deque to provide a thread-safe queue. I've adopted that, but wanted to provide a relatively full analog to ...
4
votes
1
answer
289
views
Determine concurrent access to a function
Someone asked here how to determine a function is being called from multiple threads. My take on this is that they are asking about concurrent access not sequential access. The accepted answer ...
4
votes
1
answer
535
views
Reader Writer SpinLock
I'm quite new to C++ and want to focus on writing performant multithreaded code because I will try to port our company internal GUI framework which is currently implemented in C#. So I'd love to get ...