*: use std::scoped_lock with implicit template parameter

This commit is contained in:
Max Kellermann
2024-05-23 20:43:31 +02:00
parent 4fc3230fe6
commit 381215fd73
68 changed files with 253 additions and 253 deletions

View File

@@ -109,7 +109,7 @@ public:
}
void Wait() {
std::unique_lock<Mutex> lock(mutex);
std::unique_lock lock{mutex};
cond.wait(lock, [this]{ return done; });
if (postponed_error)
@@ -130,7 +130,7 @@ protected:
}
void LockSetDone() {
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
SetDone();
}
@@ -148,7 +148,7 @@ private:
/* virtual methods from CurlResponseHandler */
void OnError(std::exception_ptr e) noexcept final {
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
postponed_error = std::move(e);
SetDone();
}

View File

@@ -140,7 +140,7 @@ private:
void SetState(State _state) noexcept {
assert(GetEventLoop().IsInside());
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
state = _state;
cond.notify_all();
}
@@ -148,7 +148,7 @@ private:
void SetState(State _state, std::exception_ptr &&e) noexcept {
assert(GetEventLoop().IsInside());
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
state = _state;
last_exception = std::move(e);
cond.notify_all();
@@ -172,7 +172,7 @@ private:
}
void WaitConnected() {
std::unique_lock<Mutex> lock(mutex);
std::unique_lock lock{mutex};
while (true) {
switch (state) {

View File

@@ -89,7 +89,7 @@ GetInfo(SmbclientContext &ctx, Mutex &mutex, const char *path)
struct stat st;
{
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
if (ctx.Stat(path, st) != 0)
throw MakeErrno("Failed to access file");
}
@@ -131,7 +131,7 @@ SmbclientStorage::OpenDirectory(std::string_view uri_utf8)
SMBCFILE *handle;
{
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
handle = ctx.OpenDirectory(mapped.c_str());
}
@@ -152,14 +152,14 @@ SkipNameFS(PathTraitsFS::const_pointer name) noexcept
SmbclientDirectoryReader::~SmbclientDirectoryReader()
{
const std::scoped_lock<Mutex> lock(storage.mutex);
const std::scoped_lock lock{storage.mutex};
storage.ctx.CloseDirectory(handle);
}
const char *
SmbclientDirectoryReader::Read() noexcept
{
const std::scoped_lock<Mutex> protect(storage.mutex);
const std::scoped_lock protect{storage.mutex};
while (auto e = storage.ctx.ReadDirectory(handle)) {
name = e->name;

View File

@@ -151,7 +151,7 @@ UdisksStorage::SetMountPoint(Path mount_point)
void
UdisksStorage::LockSetMountPoint(Path mount_point)
{
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
SetMountPoint(mount_point);
}
@@ -183,7 +183,7 @@ UdisksStorage::OnListReply(ODBus::Message reply) noexcept
return;
}
} catch (...) {
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
mount_error = std::current_exception();
want_mount = false;
cond.notify_all();
@@ -196,7 +196,7 @@ UdisksStorage::OnListReply(ODBus::Message reply) noexcept
void
UdisksStorage::MountWait()
{
std::unique_lock<Mutex> lock(mutex);
std::unique_lock lock{mutex};
if (mounted_storage)
/* already mounted */
@@ -239,7 +239,7 @@ try {
mount_request.Send(connection, *msg.Get(),
[this](auto o) { return OnMountNotify(std::move(o)); });
} catch (...) {
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
mount_error = std::current_exception();
want_mount = false;
cond.notify_all();
@@ -258,7 +258,7 @@ try {
const char *mount_path = i.GetString();
LockSetMountPoint(Path::FromFS(mount_path));
} catch (...) {
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
mount_error = std::current_exception();
want_mount = false;
cond.notify_all();
@@ -267,7 +267,7 @@ try {
void
UdisksStorage::UnmountWait()
{
std::unique_lock<Mutex> lock(mutex);
std::unique_lock lock{mutex};
if (!mounted_storage)
/* not mounted */
@@ -296,7 +296,7 @@ try {
mount_request.Send(connection, *msg.Get(),
[this](auto u) { return OnUnmountNotify(std::move(u)); });
} catch (...) {
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
mount_error = std::current_exception();
mounted_storage.reset();
cond.notify_all();
@@ -308,12 +308,12 @@ try {
using namespace ODBus;
reply.CheckThrowError();
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
mount_error = {};
mounted_storage.reset();
cond.notify_all();
} catch (...) {
const std::scoped_lock<Mutex> lock(mutex);
const std::scoped_lock lock{mutex};
mount_error = std::current_exception();
mounted_storage.reset();
cond.notify_all();