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
a0ebd444
Commit
a0ebd444
authored
Jan 15, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/SocketMonitor: add method Open()
Allow creating a closed SocketMonitor instance.
parent
0c6072c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
SocketMonitor.cxx
src/event/SocketMonitor.cxx
+22
-9
SocketMonitor.hxx
src/event/SocketMonitor.hxx
+5
-0
No files found.
src/event/SocketMonitor.cxx
View file @
a0ebd444
...
...
@@ -74,16 +74,11 @@ static GSourceFuncs socket_monitor_source_funcs = {
};
SocketMonitor
::
SocketMonitor
(
int
_fd
,
EventLoop
&
_loop
)
:
fd
(
_fd
),
loop
(
_loop
),
source
((
Source
*
)
g_source_new
(
&
socket_monitor_source_funcs
,
sizeof
(
*
source
))),
poll
{
fd
,
0
,
0
}
{
assert
(
fd
>=
0
);
:
fd
(
-
1
),
loop
(
_loop
),
source
(
nullptr
)
{
assert
(
_fd
>=
0
);
source
->
monitor
=
this
;
g_source_attach
(
&
source
->
base
,
loop
.
GetContext
());
g_source_add_poll
(
&
source
->
base
,
&
poll
);
Open
(
_fd
);
}
SocketMonitor
::~
SocketMonitor
()
...
...
@@ -93,6 +88,24 @@ SocketMonitor::~SocketMonitor()
}
void
SocketMonitor
::
Open
(
int
_fd
)
{
assert
(
fd
<
0
);
assert
(
source
==
nullptr
);
assert
(
_fd
>=
0
);
fd
=
_fd
;
poll
=
{
fd
,
0
,
0
};
source
=
(
Source
*
)
g_source_new
(
&
socket_monitor_source_funcs
,
sizeof
(
*
source
));
source
->
monitor
=
this
;
g_source_attach
(
&
source
->
base
,
loop
.
GetContext
());
g_source_add_poll
(
&
source
->
base
,
&
poll
);
}
void
SocketMonitor
::
Close
()
{
assert
(
IsDefined
());
...
...
src/event/SocketMonitor.hxx
View file @
a0ebd444
...
...
@@ -54,6 +54,9 @@ public:
static
constexpr
unsigned
ERROR
=
G_IO_ERR
;
static
constexpr
unsigned
HANGUP
=
G_IO_HUP
;
SocketMonitor
(
EventLoop
&
_loop
)
:
fd
(
-
1
),
loop
(
_loop
),
source
(
nullptr
)
{}
SocketMonitor
(
int
_fd
,
EventLoop
&
_loop
);
~
SocketMonitor
();
...
...
@@ -68,6 +71,8 @@ public:
return
fd
;
}
void
Open
(
int
_fd
);
void
Close
();
void
Schedule
(
unsigned
flags
)
{
...
...
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