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
71ed3ff9
Commit
71ed3ff9
authored
Aug 29, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/Loop: move TimerRecord::due to class TimeoutMonitor
Prepare to eliminate the TimerRecord struct.
parent
d4266d00
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
14 deletions
+28
-14
Loop.cxx
src/event/Loop.cxx
+15
-2
Loop.hxx
src/event/Loop.hxx
+7
-12
TimeoutMonitor.hxx
src/event/TimeoutMonitor.hxx
+6
-0
No files found.
src/event/Loop.cxx
View file @
71ed3ff9
...
...
@@ -27,6 +27,18 @@
#include <algorithm>
inline
std
::
chrono
::
steady_clock
::
time_point
EventLoop
::
TimerRecord
::
GetDue
()
const
noexcept
{
return
timer
.
due
;
}
inline
bool
EventLoop
::
TimerRecord
::
operator
<
(
const
TimerRecord
&
other
)
const
noexcept
{
return
timer
.
due
<
other
.
timer
.
due
;
}
EventLoop
::
EventLoop
(
ThreadId
_thread
)
:
SocketMonitor
(
*
this
),
thread
(
_thread
)
{
...
...
@@ -93,7 +105,8 @@ EventLoop::AddTimer(TimeoutMonitor &t, std::chrono::steady_clock::duration d)
{
assert
(
IsInside
());
timers
.
insert
(
TimerRecord
(
t
,
now
+
d
));
t
.
due
=
now
+
d
;
timers
.
insert
(
TimerRecord
(
t
));
again
=
true
;
}
...
...
@@ -150,7 +163,7 @@ EventLoop::Run()
break
;
}
timeout
=
i
->
due
-
now
;
timeout
=
i
->
GetDue
()
-
now
;
if
(
timeout
>
timeout
.
zero
())
break
;
...
...
src/event/Loop.hxx
View file @
71ed3ff9
...
...
@@ -51,21 +51,16 @@ class DeferredMonitor;
class
EventLoop
final
:
SocketMonitor
{
struct
TimerRecord
{
/**
* Projected monotonic_clock_ms() value when this
* timer is due.
*/
const
std
::
chrono
::
steady_clock
::
time_point
due
;
TimeoutMonitor
&
timer
;
constexpr
TimerRecord
(
TimeoutMonitor
&
_timer
,
std
::
chrono
::
steady_clock
::
time_point
_due
)
:
due
(
_due
),
timer
(
_timer
)
{}
explicit
constexpr
TimerRecord
(
TimeoutMonitor
&
_timer
)
:
timer
(
_timer
)
{}
gcc_pure
std
::
chrono
::
steady_clock
::
time_point
GetDue
()
const
noexcept
;
bool
operator
<
(
const
TimerRecord
&
other
)
const
{
return
due
<
other
.
due
;
}
gcc_pure
bool
operator
<
(
const
TimerRecord
&
other
)
const
noexcept
;
};
WakeFD
wake_fd
;
...
...
src/event/TimeoutMonitor.hxx
View file @
71ed3ff9
...
...
@@ -39,6 +39,12 @@ class TimeoutMonitor {
EventLoop
&
loop
;
/**
* When is this timer due? This is only valid if #active is
* true.
*/
std
::
chrono
::
steady_clock
::
time_point
due
;
bool
active
;
public
:
...
...
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