[PATCH] Add support for C++2a stop_token
Jonathan Wakely
jwakely@redhat.com
Fri Nov 15 14:41:00 GMT 2019
On 15/11/19 14:38 +0000, Jonathan Wakely wrote:
>On 13/11/19 17:59 -0800, Thomas Rodgers wrote:
>>+ // TODO verify the standard requires this
>>+#if 0
>>+ // register another callback
>>+ bool cb3called{false};
>>+ std::stop_callback scb3{stok, [&]
>>+ {
>>+ cb3called = true;
>>+ }};
>>+ VERIFY(ssrc.stop_possible());
>>+ VERIFY(ssrc.stop_requested());
>>+ VERIFY(stok.stop_possible());
>>+ VERIFY(stok.stop_requested());
>>+ VERIFY(!cb1called);
>>+ VERIFY(cb2called);
>>+ VERIFY(cb3called);
>>+#endif
>
>The working draft definitely requires this:
>
>Effects: Initializes callback with std::forward<C>(cb). If st.stop_requested() is true, then
>std::forward<Callback>(callback)() is evaluated in the current thread before the constructor
>returns.
I've committed this fix to the nostopstate initializer, so it defines
a variable, instead of declaring a function. I've also added a test
that uses the stop_source(nostopstate_t) constructor, and a few other
tweaks to include the new header where it's needed.
Tested powerpc64le-linux, committed to trunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 8474 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20191115/84a62bf5/attachment.bin>
More information about the Libstdc++
mailing list