Skip to content
Snippets Groups Projects
Unverified Commit f135278f authored by Jonathan Wakely's avatar Jonathan Wakely Committed by Jonathan Wakely
Browse files

libstdc++: Replace implicit lambda capture of 'this' [PR116964]

C++20 deprecates implicit capture of 'this', so change [=] to [this] for
all lambda expressions in <shared_mutex>. This only shows up on targets
where _GLIBCXX_USE_PTHREAD_RWLOCK_T is not defined, as we have an
alternative implementation of shared mutexes in that case.

libstdc++-v3/ChangeLog:

	PR libstdc++/116964
	* include/std/shared_mutex (__shared_mutex_cv): Use [this] for
	lambda captures.
	(shared_timed_mutex) [!_GLIBCXX_USE_PTHREAD_RWLOCK_T]: Likewise.
parent a96ebb2c
No related branches found
No related tags found
No related merge requests found
......@@ -332,10 +332,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
unique_lock<mutex> __lk(_M_mut);
// Wait until we can set the write-entered flag.
_M_gate1.wait(__lk, [=]{ return !_M_write_entered(); });
_M_gate1.wait(__lk, [this]{ return !_M_write_entered(); });
_M_state |= _S_write_entered;
// Then wait until there are no more readers.
_M_gate2.wait(__lk, [=]{ return _M_readers() == 0; });
_M_gate2.wait(__lk, [this]{ return _M_readers() == 0; });
}
bool
......@@ -367,7 +367,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
lock_shared()
{
unique_lock<mutex> __lk(_M_mut);
_M_gate1.wait(__lk, [=]{ return _M_state < _S_max_readers; });
_M_gate1.wait(__lk, [this]{ return _M_state < _S_max_readers; });
++_M_state;
}
......@@ -690,13 +690,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
unique_lock<mutex> __lk(_M_mut);
if (!_M_gate1.wait_until(__lk, __abs_time,
[=]{ return !_M_write_entered(); }))
[this]{ return !_M_write_entered(); }))
{
return false;
}
_M_state |= _S_write_entered;
if (!_M_gate2.wait_until(__lk, __abs_time,
[=]{ return _M_readers() == 0; }))
[this]{ return _M_readers() == 0; }))
{
_M_state ^= _S_write_entered;
// Wake all threads blocked while the write-entered flag was set.
......@@ -716,7 +716,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
unique_lock<mutex> __lk(_M_mut);
if (!_M_gate1.wait_until(__lk, __abs_time,
[=]{ return _M_state < _S_max_readers; }))
[this]{ return _M_state < _S_max_readers; }))
{
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment