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
bb2af791
Commit
bb2af791
authored
Aug 10, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/MultiSocketMonitor: add struct SingleFD
Prepare for migrating away from GLib.
parent
f3f4b332
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
MultiSocketMonitor.cxx
src/event/MultiSocketMonitor.cxx
+1
-1
MultiSocketMonitor.hxx
src/event/MultiSocketMonitor.hxx
+31
-7
No files found.
src/event/MultiSocketMonitor.cxx
View file @
bb2af791
...
...
@@ -74,7 +74,7 @@ MultiSocketMonitor::Check() const
return
true
;
for
(
const
auto
&
i
:
fds
)
if
(
i
.
revents
!=
0
)
if
(
i
.
GetReturnedEvents
()
!=
0
)
return
true
;
return
false
;
...
...
src/event/MultiSocketMonitor.hxx
View file @
bb2af791
...
...
@@ -51,10 +51,34 @@ class MultiSocketMonitor {
MultiSocketMonitor
*
monitor
;
};
struct
SingleFD
{
GPollFD
pfd
;
constexpr
SingleFD
(
gcc_unused
MultiSocketMonitor
&
m
,
int
fd
,
unsigned
events
)
:
pfd
{
fd
,
gushort
(
events
),
0
}
{}
constexpr
int
GetFD
()
const
{
return
pfd
.
fd
;
}
constexpr
unsigned
GetEvents
()
const
{
return
pfd
.
events
;
}
constexpr
unsigned
GetReturnedEvents
()
const
{
return
pfd
.
revents
;
}
void
SetEvents
(
unsigned
_events
)
{
pfd
.
events
=
_events
;
}
};
EventLoop
&
loop
;
Source
*
source
;
uint64_t
absolute_timeout_us
;
std
::
forward_list
<
GPoll
FD
>
fds
;
std
::
forward_list
<
Single
FD
>
fds
;
public
:
static
constexpr
unsigned
READ
=
G_IO_IN
;
...
...
@@ -80,8 +104,8 @@ public:
}
void
AddSocket
(
int
fd
,
unsigned
events
)
{
fds
.
push_front
({
fd
,
gushort
(
events
),
0
}
);
g_source_add_poll
(
&
source
->
base
,
&
fds
.
front
());
fds
.
emplace_front
(
*
this
,
fd
,
events
);
g_source_add_poll
(
&
source
->
base
,
&
fds
.
front
()
.
pfd
);
}
template
<
typename
E
>
...
...
@@ -89,14 +113,14 @@ public:
for
(
auto
prev
=
fds
.
before_begin
(),
end
=
fds
.
end
(),
i
=
std
::
next
(
prev
);
i
!=
end
;
i
=
std
::
next
(
prev
))
{
assert
(
i
->
events
!=
0
);
assert
(
i
->
GetEvents
()
!=
0
);
unsigned
events
=
e
(
i
->
fd
);
unsigned
events
=
e
(
i
->
GetFD
()
);
if
(
events
!=
0
)
{
i
->
events
=
events
;
i
->
SetEvents
(
events
)
;
prev
=
i
;
}
else
{
g_source_remove_poll
(
&
source
->
base
,
&
*
i
);
g_source_remove_poll
(
&
source
->
base
,
&
i
->
pfd
);
fds
.
erase_after
(
prev
);
}
}
...
...
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