Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
2 votes
0 answers
46 views

Synchronizing simulation output generation and reading using producer and consumer threads in C++

Beginner level synchronization question here. There’s a lot of material on how to implement producer-consumer synchronization. I really did try all variations that I thought made sense, but none seems ...
barak's user avatar
  • 23
-1 votes
0 answers
43 views

How to debug hanging notify_all() call in linux [closed]

I have an incidence where notify_all() does not seem to exit properly. Based on this answer notify_all() should return in any case. I have producer code in the following form: void producer() { ...
Luigsech Ingemar's user avatar
0 votes
0 answers
40 views

How would I take input and output data on multiple tmux terminal using a cpp program?

The code below creates two panes in tmux and counts down to 20. #include <iostream> #include <fstream> #include <thread> #include <vector> #include <chrono> #include <...
Karan Patel's user avatar
1 vote
3 answers
110 views

Is std::move_only_function thread safe?

Is it safe to call a std::move_only_function object in one thread and replace the function it points to in another thread? My code: #include <future> #include <functional> int main() { ...
Benjamin Buch's user avatar
0 votes
1 answer
35 views

PyTorch C++ extension: efficiently accumulate results from threads in tensor

I am implementing a PyTorch C++ extension that employs parallellism. The desired result is a N x D matrix, and each thread computes one row of this result. What is the recommended way to accumulate ...
Jonas De Schouwer's user avatar
0 votes
1 answer
46 views

Qt/QML - Getting *qml* stack trace from Non UI thread is always crashing

In a certain QML app there is a problem that sometimes QML scripts hang UI thread for very long times, like 20+ seconds of UI thread not processing any incoming events from any source. In rare cases ...
maxpovver's user avatar
  • 1,600
0 votes
0 answers
50 views

How can I add parallelism to nested loops here?

I am currently developing a c++ minecraft clone in sfml and am trying to implement parallelism for rendering and modifying the chunks using a thread pool. The main issue I am currently facing is how ...
stubbie's user avatar
1 vote
5 answers
154 views

Is statement in C++, i.e., instructions ends with semi-colon ';', executed as a whole in multi-thread context?

Say I have a std::atomic called num: std::atomic<double> num{3.1415}; as C++ does not completely support arithmetic operations for atomics except for "integral types", I cannot do: ...
PkDrew's user avatar
  • 33
3 votes
1 answer
79 views

When constructing a new std::thread, is there a point to wrapping the callable in std::bind?

I'm pretty unfamiliar with modern C++, but I've been looking at the Boost.Beast sample files and trying to understand how they work. Specifically, I've been looking at this http server sample. Here's ...
Dankmeister's user avatar
0 votes
0 answers
35 views

Is VSTest's Logger::WriteMessage not thread-safe?

I am seeing unexplained test failures when using Visual Studio 2022's VSTest's Logger::WriteMessage from multiple threads. In normal runs, I see Test Run Successful. Total tests: 26 Passed: 26 ...
bers's user avatar
  • 5,407
-1 votes
4 answers
114 views

Lock based concurrent vector

I am starting with designing thread safe data structure and looking to implement a concurrent vector that hides multi-threading complexity for the user and that offers thread safe clear function (...
omarekik's user avatar
0 votes
0 answers
61 views

Right memory_order to react on atomic increment changes in other thread?

Consider such code: #include <atomic> #include <thread> bool read_from_network() noexcept; void write_to_network() noexcept; int main() { std::atomic<size_t> work_counter; std:...
user1244932's user avatar
  • 7,932
0 votes
1 answer
63 views

Guarding tests against exit/death

I'm using googletest to test multi-threading code with std::thread. In broken code, it often happens that a std::thread is destroyed before the thread has joined, causing a program termination. ...
Hendrik's user avatar
  • 567
0 votes
0 answers
55 views

C++ threads - async takes almost the same time to execute [duplicate]

As a novice in C++ threads, I am a little bit confused. The std::async, for 1024 function calls, has almost the same duration like the 1024 calls of the same function. My intention is to demostrate (...
Kérdezösködő Indián's user avatar
1 vote
0 answers
74 views

Why am I getting cache miss while accessing a variable, only updated by the same thread?

I am trying to measure cache misses in a multi-threaded application using perf_event_open on Linux. The code involves two threads: Thread t1, that updates an aligned integer (x) and another thread t2 ...
Rishi Jain's user avatar

15 30 50 per page
1
2 3 4 5
1216