示例#1
0
文件: kqueue.go 项目: rainycape/aio
func (p poller) Add(fd int, flags Flags) error {
	var ev C.struct_kevent
	ev.ident = C.uintptr_t(fd)
	ev.flags = C.EV_ADD
	if flags&In != 0 {
		ev.filter |= C.EVFILT_READ
	}
	if flags&Out != 0 {
		ev.filter |= C.EVFILT_WRITE
	}
	if flags&OneShot != 0 {
		ev.flags |= C.EV_ONESHOT
	}
	return p.applyEvent(&ev)
}
示例#2
0
文件: kqueue.go 项目: rainycape/aio
func (p poller) Delete(fd int) error {
	var ev C.struct_kevent
	ev.ident = C.uintptr_t(fd)
	ev.filter = C.EVFILT_READ | C.EVFILT_WRITE
	ev.flags = C.EV_DELETE
	return p.applyEvent(&ev)
}