gcc/libstdc++-v3/testsuite/30_threads/unique_lock
Jonathan Wakely c556596119 libstdc++: Simplify std::try_lock and std::lock further
The std::try_lock and std::lock algorithms can use iteration instead of
recursion when all lockables have the same type and can be held by an
array of unique_lock<L> objects.

By making this change to __detail::__try_lock_impl it also benefits
__detail::__lock_impl, which uses it. For std::lock we can just put the
iterative version directly in std::lock, to avoid making any call to
__detail::__lock_impl.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

Co-authored-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/std/mutex (lock): Replace recursion with iteration
	when lockables all have the same type.
	(__detail::__try_lock_impl): Likewise. Pass lockables as
	parameters, instead of a tuple. Always lock the first one, and
	recurse for the rest.
	(__detail::__lock_impl): Adjust call to __try_lock_impl.
	(__detail::__try_to_lock): Remove.
	* testsuite/30_threads/lock/3.cc: Check that mutexes are locked.
	* testsuite/30_threads/lock/4.cc: Also test non-heterogeneous
	arguments.
	* testsuite/30_threads/unique_lock/cons/60497.cc: Also check
	std::try_lock.
	* testsuite/30_threads/try_lock/5.cc: New test.
2021-06-22 21:17:25 +01:00
..
cons libstdc++: Simplify std::try_lock and std::lock further 2021-06-22 21:17:25 +01:00
locking Update copyright years. 2021-01-04 10:26:59 +01:00
modifiers Update copyright years. 2021-01-04 10:26:59 +01:00
requirements Update copyright years. 2021-01-04 10:26:59 +01:00