FrontPage|FindPage|TitleIndex|RecentChanges|RSS TEpoll.cc
 
#include <unistd.h>
#include <sys/epoll.h>
#include "tepoll.h"

TEpoll::TEpoll(const int size)
{
    is_epoll_init = (fd_epoll = epoll_create(size)) > 0;
}

TEpoll::~TEpoll()
{
    if(is_epoll_init) close(fd_epoll);
}

int TEpoll::Do(TPEpollEvent events, int max, const int nwait)
{
    return epoll_wait(fd_epoll, events, max, nwait);
}

int TEpoll::Add(const int fd)
{      
    struct epoll_event ev;

    ev.events  = EPOLLIN | EPOLLOUT | EPOLLERR | EPOLLET;
    ev.data.fd = fd;

    return epoll_ctl(fd_epoll, EPOLL_CTL_ADD, fd, &ev);
}      

int TEpoll::Delete(const int fd)
{      
    struct epoll_event ev;
        
    ev.events  = EPOLLIN | EPOLLOUT | EPOLLERR;
    ev.data.fd = fd;
        
    return epoll_ctl(fd_epoll, EPOLL_CTL_DEL, fd, &ev);
}

last modified 2004-06-15 18:21:29
EditText|FindPage|DeletePage|LikePages|