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
bf5f12a5
Commit
bf5f12a5
authored
Jul 16, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patch-4' of
git://github.com/Wang-Yue/MPD
parents
c457d8e4
86682176
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
PosixCond.hxx
src/thread/PosixCond.hxx
+9
-9
No files found.
src/thread/PosixCond.hxx
View file @
bf5f12a5
...
...
@@ -75,13 +75,13 @@ public:
}
private
:
bool
timed_wait
(
PosixMutex
&
mutex
,
u
nsigned
timeout_m
s
)
noexcept
{
bool
timed_wait
(
PosixMutex
&
mutex
,
u
int_least32_t
timeout_u
s
)
noexcept
{
struct
timeval
now
;
gettimeofday
(
&
now
,
nullptr
);
struct
timespec
ts
;
ts
.
tv_sec
=
now
.
tv_sec
+
timeout_
ms
/
1
000
;
ts
.
tv_nsec
=
(
now
.
tv_usec
+
(
timeout_
ms
%
1000
)
*
1000
)
*
1000
;
ts
.
tv_sec
=
now
.
tv_sec
+
timeout_
us
/
1000
000
;
ts
.
tv_nsec
=
(
now
.
tv_usec
+
(
timeout_
us
%
1000000
)
)
*
1000
;
// Keep tv_nsec < 1E9 to prevent return of EINVAL
if
(
ts
.
tv_nsec
>=
1000000000
)
{
ts
.
tv_nsec
-=
1000000000
;
...
...
@@ -94,13 +94,13 @@ private:
public
:
bool
timed_wait
(
PosixMutex
&
mutex
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
noexcept
{
auto
timeout_
ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milli
seconds
>
(
timeout
).
count
();
if
(
timeout_
m
s
<
0
)
timeout_
m
s
=
0
;
else
if
(
timeout_
ms
>
std
::
numeric_limits
<
unsigned
>::
max
())
timeout_
ms
=
std
::
numeric_limits
<
unsigned
>::
max
();
auto
timeout_
us
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
micro
seconds
>
(
timeout
).
count
();
if
(
timeout_
u
s
<
0
)
timeout_
u
s
=
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_
m
s
);
return
timed_wait
(
mutex
,
timeout_
u
s
);
}
};
...
...
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