kqueue
- kqueue是一种无锁的、异步I / O模型,由4.4BSD系统发布,以替代Poll。它允许进程监听file descriptor(文件描述符)上的一系列事件,并在事件被触发时通知进程。
int kqueue(void);
int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout);
struct kevent { uintptr_t ident; short filter; u_short flags; u_int fflags; intptr_t data; void *udata; };
EV_SET(&kev, ident, filter, flags, fflags, data, udata);int kq = kqueue(); struct kevent kev;
EV_SET(&kev, fd, EVFILT_READ, EV_ADD, );
kevent(kq,&kev,1,NULL,0,NULL);