François Dumont 6ff4e7181c libstdc++: [_GLIBCXX_DEBUG] Reduce unordered containers mutex locks/unlocks
The unordered containers have 2 types of iterators, the usual ones and the
local_iterator to iterate through a given bucket. In _GLIBCXX_DEBUG mode there
are then 4 lists of iterators, 2 for iterator/const_iterator and 2 for
local_iterator/const_local_iterator.

This patch is making sure that the unordered container's mutex is only lock/unlock
1 time when those lists of iterators needed to be iterate for invalidation purpose.

Also remove calls to _M_check_rehashed after erase operations. Standard do not permit
to rehash on erase operation so we will never implement it.

libstdc++-v3/ChangeLog

	* include/debug/safe_unordered_container.h
	(_Safe_unordered_container::_M_invalidate_locals): Remove.
	(_Safe_unordered_container::_M_invalidate_all): Lock mutex while calling
	_M_invalidate_if and _M_invalidate_locals.
	(_Safe_unordered_container::_M_invalidate_all_if): New.
	(_Safe_unordered_container::_M_invalidate): New.
	(_Safe_unordered_container::_M_invalidate_if): Make private, add __scoped_lock
	argument.
	(_Safe_unordered_container::_M_invalidate_local_if): Likewise.
	* include/debug/safe_unordered_container.tcc
	(_Safe_unordered_container::_M_invalidate_if): Adapt and remove lock.
	(_Safe_unordered_container::_M_invalidate_local_if): Likewise.
	* include/debug/unordered_map
	(unordered_map::erase(const_iterator, const_iterator)): Lock before loop on
	iterators. Remove _M_check_rehashed call.
	(unordered_map::_M_self): New.
	(unordered_map::_M_invalidate): Remove.
	(unordered_map::_M_erase): Adapt and remove _M_check_rehashed call.
	(unordered_multimap::_M_erase(_Base_iterator, _Base_iterator)): New.
	(unordered_multimap::erase(_Kt&&)): Use latter.
	(unordered_multimap::erase(const key_type&)): Likewise.
	(unordered_multimap::erase(const_iterator, const_iterator)):
	Lock before loop on iterators. Remove _M_check_rehashed.
	(unordered_multimap::_M_self): New.
	(unordered_multimap::_M_invalidate): Remove.
	(unordered_multimap::_M_erase): Adapt. Remove _M_check_rehashed call.
	* include/debug/unordered_set
	(unordered_set::erase(const_iterator, const_iterator)): Add lock before loop
	for iterator invalidation. Remove _M_check_rehashed call.
	(unordered_set::_M_self): New.
	(unordered_set::_M_invalidate): Remove.
	(unordered_set::_M_erase): Adapt and remove _M_check_rehashed call.
	(unordered_multiset::_M_erase(_Base_iterator, _Base_iterator)): New.
	(unordered_multiset::erase(_Kt&&)): Use latter.
	(unordered_multiset::erase(const key_type&)): Likewise.
	(unordered_multiset::erase(const_iterator, const_iterator)):
	Lock before loop on iterators. Remove _M_check_rehashed.
	(unordered_multiset::_M_self): New.
	(unordered_multiset::_M_invalidate): Remove.
	(unordered_multiset::_M_erase): Adapt. Remove _M_check_rehashed call.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2026-03-02 19:10:14 +01:00
2026-01-02 09:56:11 +01:00
2026-02-05 00:16:28 +00:00
2026-03-02 09:49:03 +00:00
2026-02-16 00:16:25 +00:00
2026-01-10 00:16:49 +00:00
2026-02-06 00:16:39 +00:00
2026-01-02 09:56:11 +01:00
2026-02-22 00:16:27 +00:00
2026-01-02 10:47:06 +01:00
2026-01-16 00:16:30 +00:00
2026-03-02 09:49:03 +00:00
2026-01-10 00:16:49 +00:00
2026-01-30 00:16:31 +00:00
2026-02-24 00:16:30 +00:00
2026-02-24 00:16:30 +00:00
2026-02-27 00:16:38 +00:00
2026-03-02 09:49:03 +00:00
2025-12-30 00:16:33 +00:00
2026-03-02 09:49:03 +00:00
2026-01-02 09:56:11 +01:00
2026-02-27 00:16:38 +00:00
2026-02-13 00:16:32 +00:00
2026-01-02 09:56:11 +01:00
2026-02-06 00:16:39 +00:00
2026-01-02 00:16:23 +00:00
2025-12-30 00:16:33 +00:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-27 00:16:29 +00:00
2025-12-30 00:16:33 +00:00
2026-03-02 09:49:03 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.8%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.3%