コード例 #1
0
ファイル: poller.go プロジェクト: vonwenm/goczmq
// 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
ファイル: poller.go プロジェクト: jordansissel/goczmq
// 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))
}