FrontPage|FindPage|TitleIndex|RecentChanges|RSS source_ep.cc
 
ep.cc

/* ----------------------------------------------------------

 ep.cc by biscuit@actoz.com 
 for Linux 2.6.x

 v1.0 06/19/2004 first release

---------------------------------------------------------- */

#include <unistd.h>
#include <sys/epoll.h>
#include "ep.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-24 12:34:13
EditText|FindPage|DeletePage|LikePages|