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
199c8aaa
Commit
199c8aaa
authored
Jan 29, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/Loop: move code to HandleTimers()
parent
9ce6828d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
20 deletions
+33
-20
Loop.cxx
src/event/Loop.cxx
+26
-20
Loop.hxx
src/event/Loop.hxx
+7
-0
No files found.
src/event/Loop.cxx
View file @
199c8aaa
...
...
@@ -98,6 +98,29 @@ EventLoop::CancelTimer(TimerEvent &t) noexcept
timers
.
erase
(
timers
.
iterator_to
(
t
));
}
inline
std
::
chrono
::
steady_clock
::
duration
EventLoop
::
HandleTimers
()
noexcept
{
std
::
chrono
::
steady_clock
::
duration
timeout
;
while
(
!
quit
)
{
auto
i
=
timers
.
begin
();
if
(
i
==
timers
.
end
())
break
;
TimerEvent
&
t
=
*
i
;
timeout
=
t
.
due
-
now
;
if
(
timeout
>
timeout
.
zero
())
return
timeout
;
timers
.
erase
(
i
);
t
.
Run
();
}
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
/**
* Convert the given timeout specification to a milliseconds integer,
* to be used by functions like poll() and epoll_wait(). Any negative
...
...
@@ -130,26 +153,9 @@ EventLoop::Run() noexcept
/* invoke timers */
std
::
chrono
::
steady_clock
::
duration
timeout
;
while
(
true
)
{
auto
i
=
timers
.
begin
();
if
(
i
==
timers
.
end
())
{
timeout
=
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
break
;
}
TimerEvent
&
t
=
*
i
;
timeout
=
t
.
due
-
now
;
if
(
timeout
>
timeout
.
zero
())
break
;
timers
.
erase
(
i
);
t
.
Run
();
if
(
quit
)
return
;
}
const
auto
timeout
=
HandleTimers
();
if
(
quit
)
break
;
/* invoke idle */
...
...
src/event/Loop.hxx
View file @
199c8aaa
...
...
@@ -189,6 +189,13 @@ private:
*/
void
HandleDeferred
()
noexcept
;
/**
* Invoke all expired #TimerEvent instances and return the
* duration until the next timer expires. Returns a negative
* duration if there is no timeout.
*/
std
::
chrono
::
steady_clock
::
duration
HandleTimers
()
noexcept
;
bool
OnSocketReady
(
unsigned
flags
)
noexcept
override
;
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