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
98eed1f5
Commit
98eed1f5
authored
Aug 22, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/EpollFD: use class UniqueFileDescriptor
parent
5d0a463f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
14 deletions
+9
-14
EpollFD.cxx
src/system/EpollFD.cxx
+1
-1
EpollFD.hxx
src/system/EpollFD.hxx
+8
-13
No files found.
src/system/EpollFD.cxx
View file @
98eed1f5
...
...
@@ -35,7 +35,7 @@
EpollFD
::
EpollFD
()
:
fd
(
::
epoll_create1
(
EPOLL_CLOEXEC
))
{
if
(
fd
<
0
)
if
(
!
fd
.
IsDefined
()
)
throw
MakeErrno
(
"epoll_create1() failed"
);
}
...
...
src/system/EpollFD.hxx
View file @
98eed1f5
...
...
@@ -30,20 +30,21 @@
#ifndef EPOLL_FD_HXX
#define EPOLL_FD_HXX
#include "check.h"
#include "UniqueFileDescriptor.hxx"
#include <assert.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <stdint.h>
#include "check.h"
struct
epoll_event
;
/**
* A class that wraps Linux epoll.
*/
class
EpollFD
{
const
int
fd
;
UniqueFileDescriptor
fd
;
public
:
/**
...
...
@@ -51,21 +52,15 @@ public:
*/
EpollFD
();
~
EpollFD
()
noexcept
{
assert
(
fd
>=
0
);
::
close
(
fd
);
}
EpollFD
(
const
EpollFD
&
other
)
=
delete
;
EpollFD
&
operator
=
(
const
EpollFD
&
other
)
=
delete
;
EpollFD
(
EpollFD
&&
)
=
default
;
EpollFD
&
operator
=
(
EpollFD
&&
)
=
default
;
int
Wait
(
epoll_event
*
events
,
int
maxevents
,
int
timeout
)
noexcept
{
return
::
epoll_wait
(
fd
,
events
,
maxevents
,
timeout
);
return
::
epoll_wait
(
fd
.
Get
()
,
events
,
maxevents
,
timeout
);
}
bool
Control
(
int
op
,
int
_fd
,
epoll_event
*
event
)
noexcept
{
return
::
epoll_ctl
(
fd
,
op
,
_fd
,
event
)
>=
0
;
return
::
epoll_ctl
(
fd
.
Get
()
,
op
,
_fd
,
event
)
>=
0
;
}
bool
Add
(
int
_fd
,
uint32_t
events
,
void
*
ptr
)
noexcept
{
...
...
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