Method: LIBUSB::Context#next_timeout
- Defined in:
- lib/libusb/context.rb
#next_timeout ⇒ Float?
Determine the next internal timeout that libusb needs to handle.
You only need to use this function if you are calling poll() or select() or similar on libusb’s file descriptors yourself - you do not need to use it if you are calling #handle_events directly.
You should call this function in your main loop in order to determine how long to wait for select() or poll() to return results. libusb needs to be called into at this timeout, so you should use it as an upper bound on your select() or poll() call.
When the timeout has expired, call into #handle_events (perhaps in non-blocking mode) so that libusb can handle the timeout.
This function may return zero. If this is the case, it indicates that libusb has a timeout that has already expired so you should call #handle_events immediately. A return code of nil indicates that there are no pending timeouts.
On some platforms, this function will always returns nil (no pending timeouts). See libusb’s notes on time-based events.
454 455 456 457 458 459 |
# File 'lib/libusb/context.rb', line 454 def next_timeout timeval = Call::Timeval.new res = Call.libusb_get_next_timeout @ctx, timeval LIBUSB.raise_error res, "in libusb_get_next_timeout" if res<0 res == 1 ? timeval.in_s : nil end |