Talk:cpp/thread/stop token
From cppreference.com
I tried using the search for "std::stop_token" and it returned no results; I only found this page by using google search. How to fix?
- MediaWiki:Cpp-search-list-cpp should probably be updated. — Radix (talk) 15:41, 24 April 2020 (PDT)
[edit] Cancelation & Exceptions & once_flag
I saw early versions of this proposal included exceptions, which were removed with some reasonable rationale <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1677r0.pdf> however, the only way to cancel a `std::call_once(onceFlag, f);` is to throw an exception. Are there plans to address this? It seems like either `call_once` should support `stop_token` or `stop_token` or the standard should provide an exception type meaning that cancelation is happening. BenFrantzDale (talk) 04:18, 24 November 2020 (PST)
[edit] class example
A jthread stop_token example using classes would be useful.
void f1() {} void f2(std::stop_token stop_token) {} class c { static void g1() {} static void g2(std::stop_token stop_token) {} void h1() {} void h2(std::stop_token stop_token) {} // thiscall + stop_token void main() { std::jthread a1(&f1); // function std::jthread a2(&f2); // function with stop_token std::jthread b1(&s::g1); // static method std::jthread b2(&s::g2); // static method with stop_token std::jthread c1(&s::h1, this); // method // std::jthread c2(&s::h2, this);// <-- not allowed? } };