thread/Mutex: remove ScopeLock, use std::lock_guard directly

This commit is contained in:
Max Kellermann
2017-01-03 07:11:57 +01:00
parent a42021655c
commit 2e182e84c3
51 changed files with 158 additions and 160 deletions

View File

@@ -240,7 +240,7 @@ AsyncInputStream::AppendToBuffer(const void *data, size_t append_size)
void
AsyncInputStream::DeferredResume()
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
try {
Resume();
@@ -253,7 +253,7 @@ AsyncInputStream::DeferredResume()
void
AsyncInputStream::DeferredSeek()
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
if (seek_state != SeekState::SCHEDULED)
return;

View File

@@ -64,7 +64,7 @@ InputStream::WaitReady()
void
InputStream::LockWaitReady()
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
WaitReady();
}
@@ -96,14 +96,14 @@ InputStream::Seek(gcc_unused offset_type new_offset)
void
InputStream::LockSeek(offset_type _offset)
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
Seek(_offset);
}
void
InputStream::LockSkip(offset_type _offset)
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
Skip(_offset);
}
@@ -116,7 +116,7 @@ InputStream::ReadTag()
Tag *
InputStream::LockReadTag()
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
return ReadTag();
}
@@ -135,7 +135,7 @@ InputStream::LockRead(void *ptr, size_t _size)
#endif
assert(_size > 0);
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
return Read(ptr, _size);
}
@@ -164,13 +164,13 @@ InputStream::LockReadFull(void *ptr, size_t _size)
#endif
assert(_size > 0);
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
ReadFull(ptr, _size);
}
bool
InputStream::LockIsEOF()
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
return IsEOF();
}

View File

@@ -59,7 +59,7 @@ InputStream::OpenReady(const char *uri,
auto is = Open(uri, mutex, cond);
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
is->WaitReady();
is->Check();
}

View File

@@ -29,7 +29,7 @@
ThreadInputStream::~ThreadInputStream()
{
{
const ScopeLock lock(mutex);
const std::lock_guard<Mutex> lock(mutex);
close = true;
wake_cond.signal();
}
@@ -62,7 +62,7 @@ ThreadInputStream::ThreadFunc()
{
FormatThreadName("input:%s", plugin);
const ScopeLock lock(mutex);
const std::lock_guard<Mutex> lock(mutex);
try {
Open();

View File

@@ -192,7 +192,7 @@ AlsaInputStream::PrepareSockets()
void
AlsaInputStream::DispatchSockets()
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
auto w = PrepareWriteBuffer();
const snd_pcm_uframes_t w_frames = w.size / frame_size;

View File

@@ -429,7 +429,7 @@ CurlInputStream::RequestDone(CURLcode result, long status)
FreeEasy();
AsyncInputStream::SetClosed();
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
if (result != CURLE_OK) {
postponed_exception = std::make_exception_ptr(FormatRuntimeError("curl failed: %s",
@@ -693,7 +693,7 @@ CurlInputStream::DataReceived(const void *ptr, size_t received_size)
{
assert(received_size > 0);
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
if (IsSeekPending())
SeekDone();

View File

@@ -142,7 +142,7 @@ NfsInputStream::DoSeek(offset_type new_offset)
void
NfsInputStream::OnNfsFileOpen(uint64_t _size)
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
if (reconnecting) {
/* reconnect has succeeded */
@@ -162,7 +162,7 @@ NfsInputStream::OnNfsFileOpen(uint64_t _size)
void
NfsInputStream::OnNfsFileRead(const void *data, size_t data_size)
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
assert(!IsBufferFull());
assert(IsBufferFull() == (GetBufferSpace() == 0));
AppendToBuffer(data, data_size);
@@ -175,7 +175,7 @@ NfsInputStream::OnNfsFileRead(const void *data, size_t data_size)
void
NfsInputStream::OnNfsFileError(std::exception_ptr &&e)
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
if (IsPaused()) {
/* while we're paused, don't report this error to the

View File

@@ -90,7 +90,7 @@ input_smbclient_open(const char *uri,
if (!StringStartsWith(uri, "smb://"))
return nullptr;
const ScopeLock protect(smbclient_mutex);
const std::lock_guard<Mutex> protect(smbclient_mutex);
SMBCCTX *ctx = smbc_new_context();
if (ctx == nullptr)