mirror of
https://github.com/Kiritow/GSock.git
synced 2024-03-22 13:10:51 +08:00
Update epoll interface
This commit is contained in:
parent
a507c0e4a3
commit
bae91fccce
24
gsock.cpp
24
gsock.cpp
|
@ -1078,20 +1078,26 @@ epoll::~epoll()
|
|||
{
|
||||
close(_fd);
|
||||
}
|
||||
int epoll::add(const vsock& v,epoll_event* event)
|
||||
int epoll::add(const vsock& v,int event)
|
||||
{
|
||||
event->data.fd=v._vp->sfd;
|
||||
return epoll_ctl(_fd,EPOLL_CTL_ADD,v._vp->sfd,event);
|
||||
struct epoll_event ev;
|
||||
ev.events=event;
|
||||
ev.data.fd=v._vp->sfd;
|
||||
return epoll_ctl(_fd,EPOLL_CTL_ADD,v._vp->sfd,&ev);
|
||||
}
|
||||
int epoll::mod(const vsock& v,epoll_event* event)
|
||||
int epoll::mod(const vsock& v,int event)
|
||||
{
|
||||
event->data.fd=v._vp->sfd;
|
||||
return epoll_ctl(_fd,EPOLL_CTL_MOD,v._vp->sfd,event);
|
||||
struct epoll_event ev;
|
||||
ev.events=event;
|
||||
ev.data.fd=v._vp->sfd;
|
||||
return epoll_ctl(_fd,EPOLL_CTL_MOD,v._vp->sfd,&ev);
|
||||
}
|
||||
int epoll::del(const vsock& v,epoll_event* event)
|
||||
int epoll::del(const vsock& v,int event)
|
||||
{
|
||||
event->data.fd=v._vp->sfd;
|
||||
return epoll_ctl(_fd,EPOLL_CTL_DEL,v._vp->sfd,event);
|
||||
struct epoll_event ev;
|
||||
ev.events=event;
|
||||
ev.data.fd=v._vp->sfd;
|
||||
return epoll_ctl(_fd,EPOLL_CTL_DEL,v._vp->sfd,&ev);
|
||||
}
|
||||
int epoll::wait(epoll_event* events,int maxsize,int timeout)
|
||||
{
|
||||
|
|
8
gsock.h
8
gsock.h
|
@ -233,14 +233,16 @@ class epoll
|
|||
{
|
||||
public:
|
||||
epoll();
|
||||
int add(const vsock& v,epoll_event* event);
|
||||
int mod(const vsock& v,epoll_event* event);
|
||||
int del(const vsock& v,epoll_event* event);
|
||||
// EPOLLIN, EPOLLOUT, ...
|
||||
int add(const vsock& v,int event);
|
||||
int mod(const vsock& v,int event);
|
||||
int del(const vsock& v,int event);
|
||||
|
||||
// >0: event counts.
|
||||
// =0: Time up.
|
||||
// <0: Error.
|
||||
// Set timeout to -1 for infinity waiting.
|
||||
// Get data from events[i].events and events[i].data.fd
|
||||
int wait(epoll_event* events,int maxsize,int timeout);
|
||||
|
||||
~epoll();
|
||||
|
|
Loading…
Reference in New Issue
Block a user