You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The async_mutex::lock_async() method currently has the dual behaviour of allowing you to lock the mutex in such a way that requires manual unlocking (ie. no RAII) as well as allowing you to encapsulate the lock in an async_mutex_lock object that will ensure the lock is released when the lock object goes out of scope.
The behaviour is currently chosen based on whether the caller assigns the result of the co_await m.lock_async() expression to an async_mutex_lock variable.
task<T> f(async_mutex& m)
{
// Needs manual unlockingco_await m.lock_async();
m.unlock();
}
task<T> g(async_mutex& m)
{
// Lock encapsulated in RAII object
async_mutex_lock lock = co_await m.lock_async();
}
This seems potentially error-prone way of doing things.
Consider having lock_async() always require manual unlocking and introduce a new scoped_lock_async() that returns an async_mutex_lock object.
The text was updated successfully, but these errors were encountered:
The
async_mutex::lock_async()
method currently has the dual behaviour of allowing you to lock the mutex in such a way that requires manual unlocking (ie. no RAII) as well as allowing you to encapsulate the lock in anasync_mutex_lock
object that will ensure the lock is released when the lock object goes out of scope.The behaviour is currently chosen based on whether the caller assigns the result of the
co_await m.lock_async()
expression to anasync_mutex_lock
variable.This seems potentially error-prone way of doing things.
Consider having
lock_async()
always require manual unlocking and introduce a newscoped_lock_async()
that returns anasync_mutex_lock
object.The text was updated successfully, but these errors were encountered: