Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
b51bae55
Commit
b51bae55
authored
Apr 25, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread/*Cond: rename methods to match std::condition_variable
parent
5bc8cd0e
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
72 additions
and
72 deletions
+72
-72
FingerprintCommands.cxx
src/command/FingerprintCommands.cxx
+3
-3
Bridge.cxx
src/decoder/Bridge.cxx
+2
-2
Control.cxx
src/decoder/Control.cxx
+1
-1
Control.hxx
src/decoder/Control.hxx
+4
-4
Thread.cxx
src/decoder/Thread.cxx
+2
-2
Call.cxx
src/event/Call.cxx
+1
-1
BufferedInputStream.cxx
src/input/BufferedInputStream.cxx
+8
-8
BufferedInputStream.hxx
src/input/BufferedInputStream.hxx
+1
-1
CondHandler.hxx
src/input/CondHandler.hxx
+2
-2
ProxyInputStream.cxx
src/input/ProxyInputStream.cxx
+1
-1
ThreadInputStream.cxx
src/input/ThreadInputStream.cxx
+2
-2
Blocking.hxx
src/lib/nfs/Blocking.hxx
+2
-2
SmbclientNeighborPlugin.cxx
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
+2
-2
Control.cxx
src/output/Control.cxx
+3
-3
Thread.cxx
src/output/Thread.cxx
+2
-2
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+4
-4
HttpdOutputPlugin.cxx
src/output/plugins/httpd/HttpdOutputPlugin.cxx
+2
-2
SlesOutputPlugin.cxx
src/output/plugins/sles/SlesOutputPlugin.cxx
+1
-1
Control.hxx
src/player/Control.hxx
+2
-2
CurlStorage.cxx
src/storage/plugins/CurlStorage.cxx
+1
-1
NfsStorage.cxx
src/storage/plugins/NfsStorage.cxx
+2
-2
UdisksStorage.cxx
src/storage/plugins/UdisksStorage.cxx
+7
-7
PosixCond.hxx
src/thread/PosixCond.hxx
+7
-7
WindowsCond.hxx
src/thread/WindowsCond.hxx
+8
-8
run_input.cxx
test/run_input.cxx
+2
-2
No files found.
src/command/FingerprintCommands.cxx
View file @
b51bae55
...
...
@@ -67,7 +67,7 @@ protected:
void
CancelThread
()
noexcept
override
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
cancel
=
true
;
cond
.
signal
();
cond
.
notify_one
();
}
private
:
...
...
@@ -87,11 +87,11 @@ private:
/* virtual methods from class InputStreamHandler */
void
OnInputStreamReady
()
noexcept
override
{
cond
.
signal
();
cond
.
notify_one
();
}
void
OnInputStreamAvailable
()
noexcept
override
{
cond
.
signal
();
cond
.
notify_one
();
}
};
...
...
src/decoder/Bridge.cxx
View file @
b51bae55
...
...
@@ -127,7 +127,7 @@ DecoderBridge::FlushChunk() noexcept
const
std
::
lock_guard
<
Mutex
>
protect
(
dc
.
mutex
);
if
(
dc
.
client_is_waiting
)
dc
.
client_cond
.
signal
();
dc
.
client_cond
.
notify_one
();
}
bool
...
...
@@ -310,7 +310,7 @@ DecoderBridge::CommandFinished() noexcept
}
dc
.
command
=
DecoderCommand
::
NONE
;
dc
.
client_cond
.
signal
();
dc
.
client_cond
.
notify_one
();
}
SongTime
...
...
src/decoder/Control.cxx
View file @
b51bae55
...
...
@@ -67,7 +67,7 @@ DecoderControl::SetReady(const AudioFormat audio_format,
total_time
=
_duration
;
state
=
DecoderState
::
DECODE
;
client_cond
.
signal
();
client_cond
.
notify_one
();
}
bool
...
...
src/decoder/Control.hxx
View file @
b51bae55
...
...
@@ -199,7 +199,7 @@ public:
* calling this function.
*/
void
Signal
()
noexcept
{
cond
.
signal
();
cond
.
notify_one
();
}
/**
...
...
@@ -367,7 +367,7 @@ public:
assert
(
command
!=
DecoderCommand
::
NONE
);
command
=
DecoderCommand
::
NONE
;
client_cond
.
signal
();
client_cond
.
notify_one
();
}
/**
...
...
@@ -428,11 +428,11 @@ private:
/* virtual methods from class InputStreamHandler */
void
OnInputStreamReady
()
noexcept
override
{
cond
.
signal
();
cond
.
notify_one
();
}
void
OnInputStreamAvailable
()
noexcept
override
{
cond
.
signal
();
cond
.
notify_one
();
}
};
...
...
src/decoder/Thread.cxx
View file @
b51bae55
...
...
@@ -450,7 +450,7 @@ decoder_run_song(DecoderControl &dc,
throw
FormatRuntimeError
(
"Failed to decode %s"
,
error_uri
);
}
dc
.
client_cond
.
signal
();
dc
.
client_cond
.
notify_one
();
}
/**
...
...
@@ -479,7 +479,7 @@ try {
dc
.
state
=
DecoderState
::
ERROR
;
dc
.
command
=
DecoderCommand
::
NONE
;
dc
.
error
=
std
::
current_exception
();
dc
.
client_cond
.
signal
();
dc
.
client_cond
.
notify_one
();
}
void
...
...
src/event/Call.cxx
View file @
b51bae55
...
...
@@ -73,7 +73,7 @@ private:
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
done
=
true
;
cond
.
signal
();
cond
.
notify_one
();
}
};
...
...
src/input/BufferedInputStream.cxx
View file @
b51bae55
...
...
@@ -50,7 +50,7 @@ BufferedInputStream::~BufferedInputStream() noexcept
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
stop
=
true
;
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
thread
.
Join
();
...
...
@@ -81,7 +81,7 @@ BufferedInputStream::Seek(offset_type new_offset)
seek_offset
=
new_offset
;
seek
=
true
;
wake_cond
.
signal
();
wake_cond
.
notify_one
();
while
(
seek
)
client_cond
.
wait
(
mutex
);
...
...
@@ -123,21 +123,21 @@ BufferedInputStream::Read(void *ptr, size_t s)
if
(
!
IsAvailable
())
{
/* wake up the sleeping thread */
idle
=
false
;
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
return
nbytes
;
}
if
(
read_error
)
{
wake_cond
.
signal
();
wake_cond
.
notify_one
();
std
::
rethrow_exception
(
std
::
exchange
(
read_error
,
{}));
}
if
(
idle
)
{
/* wake up the sleeping thread */
idle
=
false
;
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
client_cond
.
wait
(
mutex
);
...
...
@@ -163,7 +163,7 @@ BufferedInputStream::RunThread() noexcept
idle
=
false
;
seek
=
false
;
client_cond
.
signal
();
client_cond
.
notify_one
();
}
else
if
(
!
idle
&&
!
read_error
&&
input
->
IsAvailable
()
&&
!
input
->
IsEOF
())
{
const
auto
read_offset
=
input
->
GetOffset
();
...
...
@@ -186,7 +186,7 @@ BufferedInputStream::RunThread() noexcept
input
->
Seek
(
offset
);
}
catch
(...)
{
read_error
=
std
::
current_exception
();
client_cond
.
signal
();
client_cond
.
notify_one
();
InvokeOnAvailable
();
}
}
...
...
@@ -202,7 +202,7 @@ BufferedInputStream::RunThread() noexcept
read_error
=
std
::
current_exception
();
}
client_cond
.
signal
();
client_cond
.
notify_one
();
InvokeOnAvailable
();
}
else
wake_cond
.
wait
(
mutex
);
...
...
src/input/BufferedInputStream.hxx
View file @
b51bae55
...
...
@@ -99,7 +99,7 @@ public:
}
void
OnInputStreamAvailable
()
noexcept
override
{
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
private
:
...
...
src/input/CondHandler.hxx
View file @
b51bae55
...
...
@@ -31,11 +31,11 @@ struct CondInputStreamHandler final : InputStreamHandler {
/* virtual methods from class InputStreamHandler */
void
OnInputStreamReady
()
noexcept
override
{
cond
.
signal
();
cond
.
notify_one
();
}
void
OnInputStreamAvailable
()
noexcept
override
{
cond
.
signal
();
cond
.
notify_one
();
}
};
...
...
src/input/ProxyInputStream.cxx
View file @
b51bae55
...
...
@@ -46,7 +46,7 @@ ProxyInputStream::SetInput(InputStreamPtr _input) noexcept
ready */
CopyAttributes
();
set_input_cond
.
signal
();
set_input_cond
.
notify_one
();
}
void
...
...
src/input/ThreadInputStream.cxx
View file @
b51bae55
...
...
@@ -46,7 +46,7 @@ ThreadInputStream::Stop() noexcept
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
close
=
true
;
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
Cancel
();
...
...
@@ -145,7 +145,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size)
size_t
nbytes
=
std
::
min
(
read_size
,
r
.
size
);
memcpy
(
ptr
,
r
.
data
,
nbytes
);
buffer
.
Consume
(
nbytes
);
wake_cond
.
broadcast
();
wake_cond
.
notify_all
();
offset
+=
nbytes
;
return
nbytes
;
}
...
...
src/lib/nfs/Blocking.hxx
View file @
b51bae55
...
...
@@ -61,7 +61,7 @@ private:
bool
LockWaitFinished
()
noexcept
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
while
(
!
finished
)
if
(
!
cond
.
timed_wait
(
mutex
,
timeout
))
if
(
!
cond
.
wait_for
(
mutex
,
timeout
))
return
false
;
return
true
;
...
...
@@ -74,7 +74,7 @@ private:
void
LockSetFinished
()
noexcept
{
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
finished
=
true
;
cond
.
signal
();
cond
.
notify_one
();
}
/* virtual methods from NfsLease */
...
...
src/neighbor/plugins/SmbclientNeighborPlugin.cxx
View file @
b51bae55
...
...
@@ -97,7 +97,7 @@ SmbclientNeighborExplorer::Close() noexcept
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
quit
=
true
;
cond
.
signal
();
cond
.
notify_one
();
}
thread
.
Join
();
...
...
@@ -247,7 +247,7 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept
break
;
// TODO: sleep for how long?
cond
.
timed_wait
(
mutex
,
std
::
chrono
::
seconds
(
10
));
cond
.
wait_for
(
mutex
,
std
::
chrono
::
seconds
(
10
));
}
}
...
...
src/output/Control.cxx
View file @
b51bae55
...
...
@@ -122,7 +122,7 @@ AudioOutputControl::CommandAsync(Command cmd) noexcept
assert
(
IsCommandFinished
());
command
=
cmd
;
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
void
...
...
@@ -292,7 +292,7 @@ AudioOutputControl::LockPlay() noexcept
if
(
IsOpen
()
&&
!
in_playback_loop
&&
!
woken_for_play
)
{
woken_for_play
=
true
;
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
}
...
...
@@ -340,7 +340,7 @@ AudioOutputControl::LockAllowPlay() noexcept
allow_play
=
true
;
if
(
IsOpen
())
wake_cond
.
signal
();
wake_cond
.
notify_one
();
}
void
...
...
src/output/Thread.cxx
View file @
b51bae55
...
...
@@ -39,7 +39,7 @@ AudioOutputControl::CommandFinished() noexcept
assert
(
command
!=
Command
::
NONE
);
command
=
Command
::
NONE
;
client_cond
.
signal
();
client_cond
.
notify_one
();
}
inline
void
...
...
@@ -215,7 +215,7 @@ AudioOutputControl::WaitForDelay() noexcept
if
(
delay
<=
std
::
chrono
::
steady_clock
::
duration
::
zero
())
return
true
;
(
void
)
wake_cond
.
timed_wait
(
mutex
,
delay
);
(
void
)
wake_cond
.
wait_for
(
mutex
,
delay
);
if
(
command
!=
Command
::
NONE
)
return
false
;
...
...
src/output/plugins/AlsaOutputPlugin.cxx
View file @
b51bae55
...
...
@@ -305,7 +305,7 @@ private:
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
/* notify the OutputThread that there is now
room in ring_buffer */
cond
.
signal
();
cond
.
notify_one
();
return
true
;
}
...
...
@@ -330,7 +330,7 @@ private:
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
error
=
std
::
current_exception
();
active
=
false
;
cond
.
signal
();
cond
.
notify_one
();
}
/* virtual methods from class MultiSocketMonitor */
...
...
@@ -956,7 +956,7 @@ try {
}
drain
=
false
;
cond
.
signal
();
cond
.
notify_one
();
return
;
}
}
...
...
@@ -984,7 +984,7 @@ try {
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
active
=
false
;
cond
.
signal
();
cond
.
notify_one
();
}
/* avoid race condition: see if data has
...
...
src/output/plugins/httpd/HttpdOutputPlugin.cxx
View file @
b51bae55
...
...
@@ -120,7 +120,7 @@ HttpdOutput::OnDeferredBroadcast() noexcept
/* wake up the client that may be waiting for the queue to be
flushed */
cond
.
broadcast
();
cond
.
notify_all
();
}
void
...
...
@@ -398,7 +398,7 @@ HttpdOutput::CancelAllClients() noexcept
for
(
auto
&
client
:
clients
)
client
.
CancelQueue
();
cond
.
broadcast
();
cond
.
notify_all
();
}
void
...
...
src/output/plugins/sles/SlesOutputPlugin.cxx
View file @
b51bae55
...
...
@@ -397,7 +397,7 @@ SlesOutput::PlayedCallback()
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
assert
(
n_queued
>
0
);
--
n_queued
;
cond
.
signal
();
cond
.
notify_one
();
}
static
bool
...
...
src/player/Control.hxx
View file @
b51bae55
...
...
@@ -351,7 +351,7 @@ private:
* calling this function.
*/
void
Signal
()
noexcept
{
cond
.
signal
();
cond
.
notify_one
();
}
/**
...
...
@@ -382,7 +382,7 @@ private:
void
ClientSignal
()
noexcept
{
assert
(
thread
.
IsInside
());
client_cond
.
signal
();
client_cond
.
notify_one
();
}
/**
...
...
src/storage/plugins/CurlStorage.cxx
View file @
b51bae55
...
...
@@ -138,7 +138,7 @@ protected:
request
.
Stop
();
done
=
true
;
cond
.
signal
();
cond
.
notify_one
();
}
void
LockSetDone
()
{
...
...
src/storage/plugins/NfsStorage.cxx
View file @
b51bae55
...
...
@@ -138,7 +138,7 @@ private:
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
state
=
_state
;
cond
.
broadcast
();
cond
.
notify_all
();
}
void
SetState
(
State
_state
,
std
::
exception_ptr
&&
e
)
noexcept
{
...
...
@@ -147,7 +147,7 @@ private:
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
state
=
_state
;
last_exception
=
std
::
move
(
e
);
cond
.
broadcast
();
cond
.
notify_all
();
}
void
Connect
()
noexcept
{
...
...
src/storage/plugins/UdisksStorage.cxx
View file @
b51bae55
...
...
@@ -147,7 +147,7 @@ UdisksStorage::SetMountPoint(Path mount_point)
mount_error
=
{};
want_mount
=
false
;
cond
.
broadcast
();
cond
.
notify_all
();
}
void
...
...
@@ -188,7 +188,7 @@ UdisksStorage::OnListReply(ODBus::Message reply) noexcept
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
mount_error
=
std
::
current_exception
();
want_mount
=
false
;
cond
.
broadcast
();
cond
.
notify_all
();
return
;
}
...
...
@@ -247,7 +247,7 @@ try {
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
mount_error
=
std
::
current_exception
();
want_mount
=
false
;
cond
.
broadcast
();
cond
.
notify_all
();
}
void
...
...
@@ -266,7 +266,7 @@ try {
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
mount_error
=
std
::
current_exception
();
want_mount
=
false
;
cond
.
broadcast
();
cond
.
notify_all
();
}
void
...
...
@@ -306,7 +306,7 @@ try {
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
mount_error
=
std
::
current_exception
();
mounted_storage
.
reset
();
cond
.
broadcast
();
cond
.
notify_all
();
}
void
...
...
@@ -318,12 +318,12 @@ try {
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
mount_error
=
{};
mounted_storage
.
reset
();
cond
.
broadcast
();
cond
.
notify_all
();
}
catch
(...)
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
mount_error
=
std
::
current_exception
();
mounted_storage
.
reset
();
cond
.
broadcast
();
cond
.
notify_all
();
}
std
::
string
...
...
src/thread/PosixCond.hxx
View file @
b51bae55
/*
* Copyright
(C) 2009-2015
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2009-2019
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -62,11 +62,11 @@ public:
PosixCond
(
const
PosixCond
&
other
)
=
delete
;
PosixCond
&
operator
=
(
const
PosixCond
&
other
)
=
delete
;
void
signal
()
noexcept
{
void
notify_one
()
noexcept
{
pthread_cond_signal
(
&
cond
);
}
void
broadcast
()
noexcept
{
void
notify_all
()
noexcept
{
pthread_cond_broadcast
(
&
cond
);
}
...
...
@@ -75,7 +75,7 @@ public:
}
private
:
bool
timed_wait
(
PosixMutex
&
mutex
,
uint_least32_t
timeout_us
)
noexcept
{
bool
wait_for
(
PosixMutex
&
mutex
,
uint_least32_t
timeout_us
)
noexcept
{
struct
timeval
now
;
gettimeofday
(
&
now
,
nullptr
);
...
...
@@ -92,15 +92,15 @@ private:
}
public
:
bool
timed_wait
(
PosixMutex
&
mutex
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
bool
wait_for
(
PosixMutex
&
mutex
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
auto
timeout_us
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
timeout
).
count
();
if
(
timeout_us
<
0
)
timeout_us
=
0
;
else
if
(
timeout_us
>
std
::
numeric_limits
<
uint_least32_t
>::
max
())
timeout_us
=
std
::
numeric_limits
<
uint_least32_t
>::
max
();
return
timed_wait
(
mutex
,
timeout_us
);
return
wait_for
(
mutex
,
timeout_us
);
}
};
...
...
src/thread/WindowsCond.hxx
View file @
b51bae55
/*
* Copyright
(C) 2009-2013
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2009-2019
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -48,29 +48,29 @@ public:
WindowsCond
(
const
WindowsCond
&
other
)
=
delete
;
WindowsCond
&
operator
=
(
const
WindowsCond
&
other
)
=
delete
;
void
signal
()
noexcept
{
void
notify_one
()
noexcept
{
WakeConditionVariable
(
&
cond
);
}
void
broadcast
()
noexcept
{
void
notify_all
()
noexcept
{
WakeAllConditionVariable
(
&
cond
);
}
private
:
bool
timed_wait
(
CriticalSection
&
mutex
,
DWORD
timeout_ms
)
noexcept
{
bool
wait_for
(
CriticalSection
&
mutex
,
DWORD
timeout_ms
)
noexcept
{
return
SleepConditionVariableCS
(
&
cond
,
&
mutex
.
critical_section
,
timeout_ms
);
}
public
:
bool
timed_wait
(
CriticalSection
&
mutex
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
bool
wait_for
(
CriticalSection
&
mutex
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
auto
timeout_ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
timeout
).
count
();
return
timed_wait
(
mutex
,
timeout_ms
);
return
wait_for
(
mutex
,
timeout_ms
);
}
void
wait
(
CriticalSection
&
mutex
)
noexcept
{
timed_wait
(
mutex
,
INFINITE
);
wait_for
(
mutex
,
INFINITE
);
}
};
...
...
test/run_input.cxx
View file @
b51bae55
...
...
@@ -190,14 +190,14 @@ public:
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
tag
=
std
::
move
(
_tag
);
done
=
true
;
cond
.
broadcast
();
cond
.
notify_all
();
}
void
OnRemoteTagError
(
std
::
exception_ptr
e
)
noexcept
override
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
error
=
std
::
move
(
e
);
done
=
true
;
cond
.
broadcast
();
cond
.
notify_all
();
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment