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
1473d847
Commit
1473d847
authored
4 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/PollGroup: ReadEvents() returns PollResult
parent
0ecc3394
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
14 deletions
+18
-14
Loop.cxx
src/event/Loop.cxx
+2
-2
PollGroup.hxx
src/event/PollGroup.hxx
+0
-3
PollGroupEpoll.hxx
src/event/PollGroupEpoll.hxx
+3
-1
PollGroupPoll.cxx
src/event/PollGroupPoll.cxx
+5
-2
PollGroupPoll.hxx
src/event/PollGroupPoll.hxx
+1
-1
PollGroupWinSelect.cxx
src/event/PollGroupWinSelect.cxx
+6
-4
PollGroupWinSelect.hxx
src/event/PollGroupWinSelect.hxx
+1
-1
No files found.
src/event/Loop.cxx
View file @
1473d847
...
...
@@ -257,8 +257,8 @@ EventLoop::Run() noexcept
/* wait for new event */
PollResult
poll_result
;
poll_group
.
ReadEvents
(
poll_result
,
ExportTimeoutMS
(
timeout
));
const
auto
poll_result
=
poll_group
.
ReadEvents
(
ExportTimeoutMS
(
timeout
));
ready_sockets
.
clear
();
for
(
size_t
i
=
0
;
i
<
poll_result
.
GetSize
();
++
i
)
{
...
...
This diff is collapsed.
Click to expand it.
src/event/PollGroup.hxx
View file @
1473d847
...
...
@@ -25,19 +25,16 @@
#ifdef _WIN32
#include "PollGroupWinSelect.hxx"
typedef
PollResultGeneric
PollResult
;
typedef
PollGroupWinSelect
PollGroup
;
#elif defined(USE_EPOLL)
#include "PollGroupEpoll.hxx"
typedef
PollResultEpoll
PollResult
;
typedef
PollGroupEpoll
PollGroup
;
#else
#include "PollGroupPoll.hxx"
typedef
PollResultGeneric
PollResult
;
typedef
PollGroupPoll
PollGroup
;
#endif
...
...
This diff is collapsed.
Click to expand it.
src/event/PollGroupEpoll.hxx
View file @
1473d847
...
...
@@ -61,10 +61,12 @@ public:
PollGroupEpoll
()
=
default
;
void
ReadEvents
(
PollResultEpoll
&
result
,
int
timeout_ms
)
noexcept
{
auto
ReadEvents
(
int
timeout_ms
)
noexcept
{
PollResultEpoll
result
;
int
ret
=
epoll
.
Wait
(
result
.
events
.
data
(),
result
.
events
.
size
(),
timeout_ms
);
result
.
n_events
=
std
::
max
(
0
,
ret
);
return
result
;
}
bool
Add
(
int
fd
,
unsigned
events
,
void
*
obj
)
noexcept
{
...
...
This diff is collapsed.
Click to expand it.
src/event/PollGroupPoll.cxx
View file @
1473d847
...
...
@@ -71,12 +71,13 @@ PollGroupPoll::Remove(int fd) noexcept
return
true
;
}
void
PollGroupPoll
::
ReadEvents
(
PollResultGeneric
&
result
,
int
timeout_ms
)
noexcept
PollResultGeneric
PollGroupPoll
::
ReadEvents
(
int
timeout_ms
)
noexcept
{
int
n
=
poll
(
poll_events
.
empty
()
?
nullptr
:
&
poll_events
[
0
],
poll_events
.
size
(),
timeout_ms
);
PollResultGeneric
result
;
for
(
size_t
i
=
0
;
n
>
0
&&
i
<
poll_events
.
size
();
++
i
)
{
const
auto
&
e
=
poll_events
[
i
];
if
(
e
.
revents
!=
0
)
{
...
...
@@ -84,4 +85,6 @@ PollGroupPoll::ReadEvents(PollResultGeneric &result, int timeout_ms) noexcept
--
n
;
}
}
return
result
;
}
This diff is collapsed.
Click to expand it.
src/event/PollGroupPoll.hxx
View file @
1473d847
...
...
@@ -50,7 +50,7 @@ public:
PollGroupPoll
()
noexcept
;
~
PollGroupPoll
()
noexcept
;
void
ReadEvents
(
PollResultGeneric
&
result
,
int
timeout_ms
)
noexcept
;
PollResultGeneric
ReadEvents
(
int
timeout_ms
)
noexcept
;
bool
Add
(
int
fd
,
unsigned
events
,
void
*
obj
)
noexcept
;
bool
Modify
(
int
fd
,
unsigned
events
,
void
*
obj
)
noexcept
;
bool
Remove
(
int
fd
)
noexcept
;
...
...
This diff is collapsed.
Click to expand it.
src/event/PollGroupWinSelect.cxx
View file @
1473d847
...
...
@@ -115,9 +115,8 @@ PollGroupWinSelect::Remove(SOCKET fd) noexcept
return
true
;
}
void
PollGroupWinSelect
::
ReadEvents
(
PollResultGeneric
&
result
,
int
timeout_ms
)
noexcept
PollResultGeneric
PollGroupWinSelect
::
ReadEvents
(
int
timeout_ms
)
noexcept
{
bool
use_sleep
=
event_set
[
EVENT_READ
].
IsEmpty
()
&&
event_set
[
EVENT_WRITE
].
IsEmpty
();
...
...
@@ -143,8 +142,9 @@ PollGroupWinSelect::ReadEvents(PollResultGeneric &result,
except_set
.
GetPtr
(),
timeout_ms
<
0
?
nullptr
:
&
tv
);
PollResultGeneric
result
;
if
(
ret
==
0
||
ret
==
SOCKET_ERROR
)
return
;
return
result
;
for
(
const
auto
i
:
read_set
)
items
[
i
].
events
|=
READ
;
...
...
@@ -160,4 +160,6 @@ PollGroupWinSelect::ReadEvents(PollResultGeneric &result,
result
.
Add
(
i
.
second
.
events
,
i
.
second
.
obj
);
i
.
second
.
events
=
0
;
}
return
result
;
}
This diff is collapsed.
Click to expand it.
src/event/PollGroupWinSelect.hxx
View file @
1473d847
...
...
@@ -122,7 +122,7 @@ public:
PollGroupWinSelect
()
noexcept
;
~
PollGroupWinSelect
()
noexcept
;
void
ReadEvents
(
PollResultGeneric
&
result
,
int
timeout_ms
)
noexcept
;
PollResultGeneric
ReadEvents
(
int
timeout_ms
)
noexcept
;
bool
Add
(
SOCKET
fd
,
unsigned
events
,
void
*
obj
)
noexcept
;
bool
Modify
(
SOCKET
fd
,
unsigned
events
,
void
*
obj
)
noexcept
;
bool
Remove
(
SOCKET
fd
)
noexcept
;
...
...
This diff is collapsed.
Click to expand it.
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