Skip to main content
4 votes
3 answers
299 views

I have a struct that contains a std::atomic member: #include <atomic> #include <cstdint> struct Foo { std::atomic<int64_t> value; int64_t age; }; If I allocate memory for ...
Abhishek's user avatar
  • 293
4 votes
3 answers
228 views

The code below is a fully self-contained reproduction. It contains class called Racer which models a circular ring buffer. One thread tries to advance the head repeatedly, and another thread tries to ...
Mark's user avatar
  • 5,605
4 votes
1 answer
192 views

I am encountering suspicious behavior with std::atomic_ref::is_lock_free() in Microsoft Visual Studio's C++ compiler (MSVC version 14.38.33130). The method returns true for a very large structure (...
undefined's user avatar
  • 228
11 votes
1 answer
322 views

Here is a possibly incorrect program for communicating between a function and a signal handler that might interrupt it. Assume that HandleSignal has been arranged to run as a signal handler. The ...
jacobsa's user avatar
  • 7,935
4 votes
0 answers
196 views

As the title states, I have a question about the visibility of memory operation guarantees with happens before order. I've read the cppref memory order and a previous C++ iso draft, but I still cannot ...
Haiyang He's user avatar
6 votes
1 answer
371 views

Before I get to my main question, I'm assuming that std::mutex::unlock() stops touching this as soon as it puts the mutex in a state where another thread might lock it - even though the call to unlock(...
user3188445's user avatar
  • 5,036
1 vote
1 answer
196 views

Consider this outline of a simple multi-threaded application. It has one writer thread, and ten reader threads. #include <atomic> #include <thread> const int Num_readers{...
WaltK's user avatar
  • 802
3 votes
1 answer
130 views

I'm playing around with lockless C++ programming, and I came up with a method for safely(?) transferring ownership of a non-thread-safe data structure (std::unordered_map<int, float> in my ...
Jeremy Friesner's user avatar
9 votes
1 answer
294 views

In the following program, I want to print the output as 0102030405... so on The 0 should be printed from one thread, odd values should be printed from second thread and even values from third thread....
SandeshK3112's user avatar
5 votes
0 answers
215 views

I was checking the size of std::atomic compared to T on different platforms (Windows/MSVC, Linux/GCC, Android/Clang). For intrinsic types (like int, int64_t, etc.), the size of std::atomic matches the ...
Abhishek's user avatar
  • 293
1 vote
1 answer
155 views

An acquire-like load... will keep everything (both stores and loads) BELOW the load/fence. But this doesn't mean that everything ABOVE/before the acquire-load will not move below... This means that ...
Delark's user avatar
  • 1,395
2 votes
1 answer
149 views

I’ve spent several hours studying memory orderings, but I still have some contradictions in my head. One of them concerns the Acquire/Release memory orders. Currently, my understanding is: No ...
Eugene Usachev's user avatar
1 vote
0 answers
120 views

I'm working on a cross-platform data structure and trying to define a compact union-based layout that allows atomic access to a 64-bit word, while also optionally accessing the lower 32-bit fields. I ...
Abhishek's user avatar
  • 293
1 vote
1 answer
268 views

Background I'm building a cross-platform atomic abstraction layer to support 64-bit and 128-bit atomic operations for the following types: int64_t, uint64_t __int128 (on Clang platforms) A custom ...
Abhishek's user avatar
  • 293
7 votes
0 answers
320 views

below is a copy screen from https://www.youtube.com/watch?v=5uIsadq-nyk, at 1:12:23, the line std::size_t seq2=seq.load(std::memory_order_relaxed) baffles me. I am not very familiar with the atomics, ...
Michael's user avatar
  • 810

15 30 50 per page
1
2 3 4 5
48