Пример #1
0
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
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)
}