thread/Mutex: remove ScopeLock, use std::lock_guard directly
This commit is contained in:
@@ -213,7 +213,7 @@ CompositeStorage::~CompositeStorage()
|
||||
Storage *
|
||||
CompositeStorage::GetMount(const char *uri)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
auto result = FindStorage(uri);
|
||||
if (*result.uri != 0)
|
||||
@@ -226,7 +226,7 @@ CompositeStorage::GetMount(const char *uri)
|
||||
void
|
||||
CompositeStorage::Mount(const char *uri, Storage *storage)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
Directory &directory = root.Make(uri);
|
||||
if (directory.storage != nullptr)
|
||||
@@ -237,7 +237,7 @@ CompositeStorage::Mount(const char *uri, Storage *storage)
|
||||
bool
|
||||
CompositeStorage::Unmount(const char *uri)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
return root.Unmount(uri);
|
||||
}
|
||||
@@ -266,7 +266,7 @@ CompositeStorage::FindStorage(const char *uri) const
|
||||
StorageFileInfo
|
||||
CompositeStorage::GetInfo(const char *uri, bool follow)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
std::exception_ptr error;
|
||||
|
||||
@@ -298,7 +298,7 @@ CompositeStorage::GetInfo(const char *uri, bool follow)
|
||||
StorageDirectoryReader *
|
||||
CompositeStorage::OpenDirectory(const char *uri)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
auto f = FindStorage(uri);
|
||||
const Directory *directory = f.directory->Find(f.uri);
|
||||
@@ -324,7 +324,7 @@ CompositeStorage::OpenDirectory(const char *uri)
|
||||
std::string
|
||||
CompositeStorage::MapUTF8(const char *uri) const
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
auto f = FindStorage(uri);
|
||||
if (f.directory->storage == nullptr)
|
||||
@@ -336,7 +336,7 @@ CompositeStorage::MapUTF8(const char *uri) const
|
||||
AllocatedPath
|
||||
CompositeStorage::MapFS(const char *uri) const
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
auto f = FindStorage(uri);
|
||||
if (f.directory->storage == nullptr)
|
||||
@@ -348,7 +348,7 @@ CompositeStorage::MapFS(const char *uri) const
|
||||
const char *
|
||||
CompositeStorage::MapToRelativeUTF8(const char *uri) const
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (root.storage != nullptr) {
|
||||
const char *result = root.storage->MapToRelativeUTF8(uri);
|
||||
|
@@ -110,7 +110,7 @@ public:
|
||||
*/
|
||||
template<typename T>
|
||||
void VisitMounts(T t) const {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
std::string uri;
|
||||
VisitMounts(uri, root, t);
|
||||
}
|
||||
|
@@ -133,7 +133,7 @@ private:
|
||||
void SetState(State _state) {
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
state = _state;
|
||||
cond.broadcast();
|
||||
}
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
void SetState(State _state, std::exception_ptr &&e) {
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
state = _state;
|
||||
last_exception = std::move(e);
|
||||
cond.broadcast();
|
||||
@@ -164,7 +164,7 @@ private:
|
||||
}
|
||||
|
||||
void WaitConnected() {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
while (true) {
|
||||
switch (state) {
|
||||
|
@@ -97,7 +97,7 @@ GetInfo(const char *path)
|
||||
struct stat st;
|
||||
|
||||
{
|
||||
const ScopeLock protect(smbclient_mutex);
|
||||
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
||||
if (smbc_stat(path, &st) != 0)
|
||||
throw MakeErrno("Failed to access file");
|
||||
}
|
||||
@@ -132,7 +132,7 @@ SmbclientStorage::OpenDirectory(const char *uri_utf8)
|
||||
int handle;
|
||||
|
||||
{
|
||||
const ScopeLock protect(smbclient_mutex);
|
||||
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
||||
handle = smbc_opendir(mapped.c_str());
|
||||
if (handle < 0)
|
||||
throw MakeErrno("Failed to open directory");
|
||||
@@ -160,7 +160,7 @@ SmbclientDirectoryReader::~SmbclientDirectoryReader()
|
||||
const char *
|
||||
SmbclientDirectoryReader::Read()
|
||||
{
|
||||
const ScopeLock protect(smbclient_mutex);
|
||||
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
||||
|
||||
struct smbc_dirent *e;
|
||||
while ((e = smbc_readdir(handle)) != nullptr) {
|
||||
@@ -187,7 +187,7 @@ CreateSmbclientStorageURI(gcc_unused EventLoop &event_loop, const char *base)
|
||||
|
||||
SmbclientInit();
|
||||
|
||||
const ScopeLock protect(smbclient_mutex);
|
||||
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
||||
SMBCCTX *ctx = smbc_new_context();
|
||||
if (ctx == nullptr)
|
||||
throw MakeErrno("smbc_new_context() failed");
|
||||
|
Reference in New Issue
Block a user