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
b611b182
Commit
b611b182
authored
Oct 15, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/Loop: move code to Wait()
parent
1473d847
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
9 deletions
+25
-9
Loop.cxx
src/event/Loop.cxx
+17
-9
Loop.hxx
src/event/Loop.hxx
+8
-0
No files found.
src/event/Loop.cxx
View file @
b611b182
...
...
@@ -184,6 +184,22 @@ ExportTimeoutMS(Event::Duration timeout)
:
-
1
;
}
inline
bool
EventLoop
::
Wait
(
Event
::
Duration
timeout
)
noexcept
{
const
auto
poll_result
=
poll_group
.
ReadEvents
(
ExportTimeoutMS
(
timeout
));
ready_sockets
.
clear
();
for
(
size_t
i
=
0
;
i
<
poll_result
.
GetSize
();
++
i
)
{
auto
&
s
=
*
(
SocketEvent
*
)
poll_result
.
GetObject
(
i
);
s
.
SetReadyFlags
(
poll_result
.
GetEvents
(
i
));
ready_sockets
.
push_back
(
s
);
}
return
poll_result
.
GetSize
()
>
0
;
}
void
EventLoop
::
Run
()
noexcept
{
...
...
@@ -257,15 +273,7 @@ EventLoop::Run() noexcept
/* wait for new event */
const
auto
poll_result
=
poll_group
.
ReadEvents
(
ExportTimeoutMS
(
timeout
));
ready_sockets
.
clear
();
for
(
size_t
i
=
0
;
i
<
poll_result
.
GetSize
();
++
i
)
{
auto
&
s
=
*
(
SocketEvent
*
)
poll_result
.
GetObject
(
i
);
s
.
SetReadyFlags
(
poll_result
.
GetEvents
(
i
));
ready_sockets
.
push_back
(
s
);
}
Wait
(
timeout
);
now
=
std
::
chrono
::
steady_clock
::
now
();
...
...
src/event/Loop.hxx
View file @
b611b182
...
...
@@ -258,6 +258,14 @@ private:
*/
Event
::
Duration
HandleTimers
()
noexcept
;
/**
* Call epoll_wait() and pass all returned events to
* SocketEvent::SetReadyFlags().
*
* @return true if one or more sockets have become ready
*/
bool
Wait
(
Event
::
Duration
timeout
)
noexcept
;
#ifdef HAVE_THREADED_EVENT_LOOP
void
OnSocketReady
(
unsigned
flags
)
noexcept
;
#endif
...
...
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