4 ms·
Thanks, I wrote the sample code for the std::latch and std::barrier pages. [Unfortunately you can't run them in place, because the compiler backing it is too ol
by ncmncm 6y ago
Thanks, I wrote the sample code for the std::latch and std::barrier pages. [Unfortunately you can't run them in place, because the compiler backing it is too old. I am wrong! Now you can.] But you can paste them into Godbolt.org and run there, given a bit of compiler link-line fu.
std::barrier has extra knobs that I didn't discover a good use for, or would have used them in the sample. Enlightenment welcome.
This might be a good place to mention: cppreference.com is curated by ISO Standard C++ committee participants. (Cplusplus.com, by contrast, is very poorly maintained.) If cppreference disagrees from the Standard, it is likely that the Standard will soon be amended to match.
Speaking of Godbolt: it enforces a limit of three spawned threads, but the Gcc and Clang thread sanitizers use up a thread. So if you want to try the samples on Godbolt under the thread sanitizer, you have to reduce the problem sizes to two. Learned that the hard way.
- kitd 6y agoFWIW, I did a lot of C++ in the 1990s, then went to Java/Go for about 15 years. I had to come back to C++ briefly about 5 years ago. cppreference was a total godsend!
- diath 6y ago> Unfortunately you can't run them in place, because the compiler backing it is too old. Are you sure you've not changed the dropdown? I just made some changes to the example, hit "run this code", hit "run", and the output updated accordingly.
- ncmncm 6y agoOops, you're right -- they updated compiler support! Good news.
- klyrs 5y agoI realize that you'd be demonstrating even less of the featureset, but it seems that you could have used arrive_and_wait on a single latch.