Пример #1
0
// Wait waits for the timeout period in milliseconds for a Pollin
// event, and returns the first socket that returns one
func (p *Poller) Wait(millis int) *Sock {
	s := C.zpoller_wait(p.zpollerT, C.int(millis))
	s = unsafe.Pointer(s)
	if s == nil {
		return nil
	}
	for _, sock := range p.socks {
		if unsafe.Pointer(sock.zsockT) == s {
			return sock
		}
	}

	panic(fmt.Sprintf(
		"Could not match received pointer with %v with any socket (%v)",
		s, p.socks))
}
Пример #2
0
// Wait waits for the timeout period in milliseconds for a Pollin
// event, and returns the first socket that returns one
func (p *Poller) Wait(millis int) *Sock {
	if p.zpollerT == nil {
		// Null pointer. Something is wrong or we've already had `Destroy` invoked on us.
		panic(WaitAfterDestroyPanicMessage)
	}
	s := C.zpoller_wait(p.zpollerT, C.int(millis))
	s = unsafe.Pointer(s)
	if s == nil {
		return nil
	}
	for _, sock := range p.socks {
		if unsafe.Pointer(sock.zsockT) == s {
			return sock
		}
	}

	panic(fmt.Sprintf(
		"Could not match received pointer with %v with any socket (%v)",
		s, p.socks))
}