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
ae35df11
Commit
ae35df11
authored
May 08, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zeroconf/AvahiPoll: move TimevalToChrono() to time/Convert.cxx
parent
80e55f6b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
8 deletions
+15
-8
Convert.cxx
src/time/Convert.cxx
+7
-0
Convert.hxx
src/time/Convert.hxx
+4
-0
AvahiPoll.cxx
src/zeroconf/AvahiPoll.cxx
+3
-8
meson.build
src/zeroconf/meson.build
+1
-0
No files found.
src/time/Convert.cxx
View file @
ae35df11
...
...
@@ -81,3 +81,10 @@ MakeTime(struct tm &tm) noexcept
{
return
std
::
chrono
::
system_clock
::
from_time_t
(
mktime
(
&
tm
));
}
std
::
chrono
::
steady_clock
::
duration
ToSteadyClockDuration
(
const
struct
timeval
&
tv
)
noexcept
{
return
std
::
chrono
::
steady_clock
::
duration
(
std
::
chrono
::
seconds
(
tv
.
tv_sec
))
+
std
::
chrono
::
steady_clock
::
duration
(
std
::
chrono
::
microseconds
(
tv
.
tv_usec
));
}
src/time/Convert.hxx
View file @
ae35df11
...
...
@@ -67,4 +67,8 @@ gcc_pure
std
::
chrono
::
system_clock
::
time_point
MakeTime
(
struct
tm
&
tm
)
noexcept
;
gcc_pure
std
::
chrono
::
steady_clock
::
duration
ToSteadyClockDuration
(
const
struct
timeval
&
tv
)
noexcept
;
#endif
src/zeroconf/AvahiPoll.cxx
View file @
ae35df11
...
...
@@ -20,6 +20,7 @@
#include "AvahiPoll.hxx"
#include "event/SocketMonitor.hxx"
#include "event/TimerEvent.hxx"
#include "time/Convert.hxx"
static
unsigned
FromAvahiWatchEvent
(
AvahiWatchEvent
e
)
...
...
@@ -78,12 +79,6 @@ private:
}
};
static
constexpr
std
::
chrono
::
steady_clock
::
duration
TimevalToChrono
(
const
timeval
&
tv
)
{
return
std
::
chrono
::
seconds
(
tv
.
tv_sec
)
+
std
::
chrono
::
microseconds
(
tv
.
tv_usec
);
}
struct
AvahiTimeout
final
{
TimerEvent
timer
;
...
...
@@ -97,12 +92,12 @@ public:
:
timer
(
_loop
,
BIND_THIS_METHOD
(
OnTimeout
)),
callback
(
_callback
),
userdata
(
_userdata
)
{
if
(
tv
!=
nullptr
)
timer
.
Schedule
(
T
imevalToChrono
(
*
tv
));
timer
.
Schedule
(
T
oSteadyClockDuration
(
*
tv
));
}
static
void
TimeoutUpdate
(
AvahiTimeout
*
t
,
const
struct
timeval
*
tv
)
{
if
(
tv
!=
nullptr
)
t
->
timer
.
Schedule
(
T
imevalToChrono
(
*
tv
));
t
->
timer
.
Schedule
(
T
oSteadyClockDuration
(
*
tv
));
else
t
->
timer
.
Cancel
();
}
...
...
src/zeroconf/meson.build
View file @
ae35df11
...
...
@@ -67,6 +67,7 @@ else
dependencies: [
libavahi_client_dep,
dbus_dep,
time_dep,
],
)
...
...
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