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
ad4ca0c4
Commit
ad4ca0c4
authored
May 07, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread/*Cond: remove wait() overloads without std::unique_lock<>
parent
0a0cc66e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
39 deletions
+16
-39
PosixCond.hxx
src/thread/PosixCond.hxx
+8
-17
WindowsCond.hxx
src/thread/WindowsCond.hxx
+8
-22
No files found.
src/thread/PosixCond.hxx
View file @
ad4ca0c4
...
...
@@ -71,17 +71,13 @@ public:
pthread_cond_broadcast
(
&
cond
);
}
void
wait
(
PosixMutex
&
mutex
)
noexcept
{
pthread_cond_wait
(
&
cond
,
&
mutex
.
mutex
);
}
template
<
typename
M
>
void
wait
(
std
::
unique_lock
<
M
>
&
lock
)
noexcept
{
wait
(
*
lock
.
mutex
());
void
wait
(
std
::
unique_lock
<
PosixMutex
>
&
lock
)
noexcept
{
pthread_cond_wait
(
&
cond
,
&
lock
.
mutex
()
->
mutex
);
}
private
:
bool
wait_for
(
PosixMutex
&
mutex
,
uint_least32_t
timeout_us
)
noexcept
{
bool
wait_for
(
std
::
unique_lock
<
PosixMutex
>
&
lock
,
uint_least32_t
timeout_us
)
noexcept
{
struct
timeval
now
;
gettimeofday
(
&
now
,
nullptr
);
...
...
@@ -94,11 +90,12 @@ private:
ts
.
tv_sec
++
;
}
return
pthread_cond_timedwait
(
&
cond
,
&
mutex
.
mutex
,
&
ts
)
==
0
;
return
pthread_cond_timedwait
(
&
cond
,
&
lock
.
mutex
()
->
mutex
,
&
ts
)
==
0
;
}
public
:
bool
wait_for
(
PosixMutex
&
mutex
,
template
<
typename
M
>
bool
wait_for
(
std
::
unique_lock
<
M
>
&
lock
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
auto
timeout_us
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
timeout
).
count
();
if
(
timeout_us
<
0
)
...
...
@@ -106,13 +103,7 @@ public:
else
if
(
timeout_us
>
std
::
numeric_limits
<
uint_least32_t
>::
max
())
timeout_us
=
std
::
numeric_limits
<
uint_least32_t
>::
max
();
return
wait_for
(
mutex
,
timeout_us
);
}
template
<
typename
M
>
bool
wait_for
(
std
::
unique_lock
<
M
>
&
lock
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
return
wait_for
(
*
lock
.
mutex
(),
timeout
);
return
wait_for
(
lock
,
timeout_us
);
}
};
...
...
src/thread/WindowsCond.hxx
View file @
ad4ca0c4
...
...
@@ -57,32 +57,18 @@ public:
WakeAllConditionVariable
(
&
cond
);
}
private
:
bool
wait_for
(
CriticalSection
&
mutex
,
DWORD
timeout_ms
)
noexcept
{
return
SleepConditionVariableCS
(
&
cond
,
&
mutex
.
critical_section
,
timeout_ms
);
void
wait
(
std
::
unique_lock
<
CriticalSection
>
&
lock
)
noexcept
{
SleepConditionVariableCS
(
&
cond
,
&
lock
.
mutex
()
->
critical_section
,
INFINITE
);
}
public
:
bool
wait_for
(
CriticalSection
&
mutex
,
bool
wait_for
(
std
::
unique_lock
<
CriticalSection
>
&
lock
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
auto
timeout_ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
timeout
).
count
();
return
wait_for
(
mutex
,
timeout_ms
);
}
template
<
typename
M
>
bool
wait_for
(
std
::
unique_lock
<
M
>
&
lock
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
return
wait_for
(
*
lock
.
mutex
(),
timeout
);
}
void
wait
(
CriticalSection
&
mutex
)
noexcept
{
wait_for
(
mutex
,
INFINITE
);
}
template
<
typename
M
>
void
wait
(
std
::
unique_lock
<
M
>
&
lock
)
noexcept
{
wait
(
*
lock
.
mutex
());
return
SleepConditionVariableCS
(
&
cond
,
&
lock
.
mutex
()
->
critical_section
,
timeout_ms
);
}
};
...
...
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