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

@@ -88,7 +88,7 @@ need_chunks(DecoderControl &dc)
static DecoderCommand
LockNeedChunks(DecoderControl &dc)
{
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
return need_chunks(dc);
}
@@ -130,7 +130,7 @@ DecoderBridge::FlushChunk()
else
dc.pipe->Push(chunk);
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
if (dc.client_is_waiting)
dc.client_cond.signal();
}
@@ -193,7 +193,7 @@ DecoderBridge::GetVirtualCommand()
DecoderCommand
DecoderBridge::LockGetVirtualCommand()
{
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
return GetVirtualCommand();
}
@@ -258,7 +258,7 @@ DecoderBridge::Ready(const AudioFormat audio_format,
seekable ? "true" : "false");
{
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
dc.SetReady(audio_format, seekable, duration);
}
@@ -287,7 +287,7 @@ DecoderBridge::GetCommand()
void
DecoderBridge::CommandFinished()
{
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
assert(dc.command != DecoderCommand::NONE || initial_seek_running);
assert(dc.command != DecoderCommand::SEEK ||
@@ -376,7 +376,7 @@ DecoderBridge::OpenUri(const char *uri)
auto is = InputStream::Open(uri, mutex, cond);
const ScopeLock lock(mutex);
const std::lock_guard<Mutex> lock(mutex);
while (true) {
is->Update();
if (is->IsReady())
@@ -399,7 +399,7 @@ try {
if (length == 0)
return 0;
ScopeLock lock(is.mutex);
std::lock_guard<Mutex> lock(is.mutex);
while (true) {
if (CheckCancelRead())

View File

@@ -111,7 +111,7 @@ DecoderControl::Start(DetachedSong *_song,
void
DecoderControl::Stop()
{
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
if (command != DecoderCommand::NONE)
/* Attempt to cancel the current command. If it's too

View File

@@ -228,7 +228,7 @@ struct DecoderControl {
gcc_pure
bool LockIsIdle() const {
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
return IsIdle();
}
@@ -238,7 +238,7 @@ struct DecoderControl {
gcc_pure
bool LockIsStarting() const {
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
return IsStarting();
}
@@ -250,7 +250,7 @@ struct DecoderControl {
gcc_pure
bool LockHasFailed() const {
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
return HasFailed();
}
@@ -281,7 +281,7 @@ struct DecoderControl {
* Like CheckRethrowError(), but locks and unlocks the object.
*/
void LockCheckRethrowError() const {
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
CheckRethrowError();
}
@@ -309,7 +309,7 @@ struct DecoderControl {
gcc_pure
bool LockIsCurrentSong(const DetachedSong &_song) const {
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
return IsCurrentSong(_song);
}
@@ -346,13 +346,13 @@ private:
* object.
*/
void LockSynchronousCommand(DecoderCommand cmd) {
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
ClearError();
SynchronousCommandLocked(cmd);
}
void LockAsynchronousCommand(DecoderCommand cmd) {
const ScopeLock protect(mutex);
const std::lock_guard<Mutex> protect(mutex);
command = cmd;
Signal();
}

View File

@@ -61,7 +61,7 @@ decoder_input_stream_open(DecoderControl &dc, const char *uri)
/* wait for the input stream to become ready; its metadata
will be available then */
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
is->Update();
while (!is->IsReady()) {
@@ -264,7 +264,7 @@ static void
MaybeLoadReplayGain(DecoderBridge &bridge, InputStream &is)
{
{
const ScopeLock protect(bridge.dc.mutex);
const std::lock_guard<Mutex> protect(bridge.dc.mutex);
if (bridge.dc.replay_gain_mode == ReplayGainMode::OFF)
/* ReplayGain is disabled */
return;
@@ -288,7 +288,7 @@ decoder_run_stream(DecoderBridge &bridge, const char *uri)
MaybeLoadReplayGain(bridge, *input_stream);
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
bool tried = false;
return dc.command == DecoderCommand::STOP ||
@@ -318,10 +318,10 @@ TryDecoderFile(DecoderBridge &bridge, Path path_fs, const char *suffix,
DecoderControl &dc = bridge.dc;
if (plugin.file_decode != nullptr) {
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
return decoder_file_decode(plugin, bridge, path_fs);
} else if (plugin.stream_decode != nullptr) {
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
return decoder_stream_decode(plugin, bridge, input_stream);
} else
return false;
@@ -344,7 +344,7 @@ TryContainerDecoder(DecoderBridge &bridge, Path path_fs, const char *suffix,
bridge.error = nullptr;
DecoderControl &dc = bridge.dc;
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
return decoder_file_decode(plugin, bridge, path_fs);
}
@@ -517,7 +517,7 @@ decoder_task(void *arg)
SetThreadName("decoder");
const ScopeLock protect(dc.mutex);
const std::lock_guard<Mutex> protect(dc.mutex);
do {
assert(dc.state == DecoderState::STOP ||