8sa1-gcc/libstdc++-v3/include/std
Jonathan Wakely 0a8f4febf7 libstdc++: Fix conformance issues in <stop_token> (PR92895)
Fix synchronization issues in <stop_token>. Replace shared_ptr with
_Stop_state_ref and a reference count embedded in the shared state.
Replace std::mutex with spinlock using one bit of a std::atomic<> that
also tracks whether a stop request has been made and how many
stop_source objects share ownership of the state.

	PR libstdc++/92895
	* include/std/stop_token (stop_token::stop_possible()): Call new
	_M_stop_possible() function.
	(stop_token::stop_requested()): Do not use stop_possible().
	(stop_token::binary_semaphore): New class, as temporary stand-in for
	std::binary_semaphore.
	(stop_token::_Stop_cb::_M_callback): Add noexcept to type.
	(stop_token::_Stop_cb::_M_destroyed, stop_token::_Stop_cb::_M_done):
	New data members for symchronization with stop_callback destruction.
	(stop_token::_Stop_cb::_Stop_cb): Make non-template.
	(stop_token::_Stop_cb::_M_linked, stop_token::_Stop_cb::_S_execute):
	Remove.
	(stop_token::_Stop_cb::_M_run): New member function.
	(stop_token::_Stop_state::_M_stopped, stop_token::_Stop_state::_M_mtx):
	Remove.
	(stop_token::_Stop_state::_M_owners): New data member to track
	reference count for ownership.
	(stop_token::_Stop_state::_M_value): New data member combining a
	spinlock, the stop requested flag, and the reference count for
	associated stop_source objects.
	(stop_token::_Stop_state::_M_requester): New data member for
	synchronization with stop_callback destruction.
	(stop_token::_Stop_state::_M_stop_possible()): New member function.
	(stop_token::_Stop_state::_M_stop_requested()): Inspect relevant bit
	of _M_value.
	(stop_token::_Stop_state::_M_add_owner)
	(stop_token::_Stop_state::_M_release_ownership)
	(stop_token::_Stop_state::_M_add_ssrc)
	(stop_token::_Stop_state::_M_sub_ssrc): New member functions for
	updating reference counts.
	(stop_token::_Stop_state::_M_lock, stop_token::_Stop_state::_M_unlock)
	(stop_token::_Stop_state::_M_lock, stop_token::_Stop_state::_M_unlock)
	(stop_token::_Stop_state::_M_try_lock)
	(stop_token::_Stop_state::_M_try_lock_and_stop)
	(stop_token::_Stop_state::_M_do_try_lock): New member functions for
	managing spinlock.
	(stop_token::_Stop_state::_M_request_stop): Use atomic operations to
	read and update state. Release lock while running callbacks. Use new
	data members to synchronize with callback destruction.
	(stop_token::_Stop_state::_M_remove_callback): Likewise.
	(stop_token::_Stop_state::_M_register_callback): Use atomic operations
	to read and update state.
	(stop_token::_Stop_state_ref): Handle type to manage _Stop_state,
	replacing shared_ptr.
	(stop_source::stop_source(const stop_source&)): Update reference count.
	(stop_source::operator=(const stop_source&)): Likewise.
	(stop_source::~stop_source()): Likewise.
	(stop_source::stop_source(stop_source&&)): Define as defaulted.
	(stop_source::operator=(stop_source&&)): Establish postcondition on
	parameter.
	(stop_callback): Enforce preconditions on template parameter. Replace
	base class with data member of new _Cb_impl type.
	(stop_callback::stop_callback(const stop_token&, Cb&&))
	(stop_callback::stop_callback(stop_token&&, Cb&&)): Fix TOCTTOU race.
	(stop_callback::_Cb_impl): New type wrapping _Callback member and
	defining the _S_execute member function.
	* testsuite/30_threads/stop_token/stop_callback/deadlock-mt.cc: New
	test.
	* testsuite/30_threads/stop_token/stop_callback/deadlock.cc: New test.
	* testsuite/30_threads/stop_token/stop_callback/destroy.cc: New test.
	* testsuite/30_threads/stop_token/stop_callback/destructible_neg.cc:
	New test.
	* testsuite/30_threads/stop_token/stop_callback/invocable_neg.cc: New
	test.
	* testsuite/30_threads/stop_token/stop_callback/invoke.cc: New test.
	* testsuite/30_threads/stop_token/stop_source/assign.cc: New test.
	* testsuite/30_threads/stop_token/stop_token/stop_possible.cc: New
	test.
2020-01-29 15:52:08 +00:00
..
algorithm Update copyright years. 2020-01-01 12:51:42 +01:00
any Update copyright years. 2020-01-01 12:51:42 +01:00
array Update copyright years. 2020-01-01 12:51:42 +01:00
atomic Fix 2 typos in documentation of libstdc++. 2020-01-28 10:25:30 +01:00
bit Update copyright years. 2020-01-01 12:51:42 +01:00
bitset Update copyright years. 2020-01-01 12:51:42 +01:00
charconv Update copyright years. 2020-01-01 12:51:42 +01:00
chrono Update copyright years. 2020-01-01 12:51:42 +01:00
codecvt Update copyright years. 2020-01-01 12:51:42 +01:00
complex Update copyright years. 2020-01-01 12:51:42 +01:00
concepts Update copyright years. 2020-01-01 12:51:42 +01:00
condition_variable Rename condition_variable_any wait* methods to match current draft standard 2020-01-08 03:00:40 +00:00
coroutine [C++ coroutines] Initial implementation. 2020-01-18 11:55:56 +00:00
deque Update copyright years. 2020-01-01 12:51:42 +01:00
execution Update copyright years. 2020-01-01 12:51:42 +01:00
filesystem Update copyright years. 2020-01-01 12:51:42 +01:00
forward_list Update copyright years. 2020-01-01 12:51:42 +01:00
fstream Update copyright years. 2020-01-01 12:51:42 +01:00
functional Update copyright years. 2020-01-01 12:51:42 +01:00
future Update copyright years. 2020-01-01 12:51:42 +01:00
iomanip Update copyright years. 2020-01-01 12:51:42 +01:00
ios Update copyright years. 2020-01-01 12:51:42 +01:00
iosfwd Update copyright years. 2020-01-01 12:51:42 +01:00
iostream Update copyright years. 2020-01-01 12:51:42 +01:00
istream Update copyright years. 2020-01-01 12:51:42 +01:00
iterator Update copyright years. 2020-01-01 12:51:42 +01:00
limits Update copyright years. 2020-01-01 12:51:42 +01:00
list Update copyright years. 2020-01-01 12:51:42 +01:00
locale Update copyright years. 2020-01-01 12:51:42 +01:00
map Update copyright years. 2020-01-01 12:51:42 +01:00
memory Update copyright years. 2020-01-01 12:51:42 +01:00
memory_resource libstdc++: Define memory resource key functions non-inline (PR93208) 2020-01-09 13:18:20 +00:00
mutex Update copyright years. 2020-01-01 12:51:42 +01:00
numbers Update copyright years. 2020-01-01 12:51:42 +01:00
numeric Update copyright years. 2020-01-01 12:51:42 +01:00
optional Fix 2 typos in documentation of libstdc++. 2020-01-28 10:25:30 +01:00
ostream Update copyright years. 2020-01-01 12:51:42 +01:00
queue Update copyright years. 2020-01-01 12:51:42 +01:00
random Update copyright years. 2020-01-01 12:51:42 +01:00
ranges libstdc++: Fix weakly_incrementable to allow __int128 (PR 93267) 2020-01-15 16:22:49 +00:00
ratio Update copyright years. 2020-01-01 12:51:42 +01:00
regex Update copyright years. 2020-01-01 12:51:42 +01:00
scoped_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
set Update copyright years. 2020-01-01 12:51:42 +01:00
shared_mutex Update copyright years. 2020-01-01 12:51:42 +01:00
span libstdc++: Fix deduction guide for std::span (PR93426) 2020-01-27 10:55:19 +00:00
sstream Update copyright years. 2020-01-01 12:51:42 +01:00
stack Update copyright years. 2020-01-01 12:51:42 +01:00
stdexcept Update copyright years. 2020-01-01 12:51:42 +01:00
stop_token libstdc++: Fix conformance issues in <stop_token> (PR92895) 2020-01-29 15:52:08 +00:00
streambuf Update copyright years. 2020-01-01 12:51:42 +01:00
string Update copyright years. 2020-01-01 12:51:42 +01:00
string_view Update copyright years. 2020-01-01 12:51:42 +01:00
system_error Update copyright years. 2020-01-01 12:51:42 +01:00
thread Update copyright years. 2020-01-01 12:51:42 +01:00
tuple Update copyright years. 2020-01-01 12:51:42 +01:00
type_traits libstdc++: Fix testsuite failures and warnings due to is_pod deprecation 2020-01-09 21:31:50 +00:00
typeindex Update copyright years. 2020-01-01 12:51:42 +01:00
unordered_map Update copyright years. 2020-01-01 12:51:42 +01:00
unordered_set Update copyright years. 2020-01-01 12:51:42 +01:00
utility Update copyright years. 2020-01-01 12:51:42 +01:00
valarray Update copyright years. 2020-01-01 12:51:42 +01:00
variant Update copyright years. 2020-01-01 12:51:42 +01:00
vector Update copyright years. 2020-01-01 12:51:42 +01:00
version libstdc++: Value-initialize std::atomic for C++20 (P0883R2) 2020-01-13 13:22:28 +00:00