ringbuf: Allow poll() to block for an indefinite time period
ring_buffer__poll in libbpf internally calls epoll_wait. Specifying a timeout of -1 to epoll_wait causes it to block indefinitely if no event transpires. We should support this functionality in libbpf-rs as well.
Currently in libbpf-rs, ringbuf's poll only takes in a Duration for the timeout, which therefore cannot be negative. In this change, poll is modified to take in an Option. If the user passes in None for the timeout, then this means that poll() should block indefinitely until an event occurs.
Signed-off-by: Joanne Koong [email protected]
An alternative would be to introduce a new function like epoll_indefinite
Couldn't you check if the value is Duration::MAX and pass -1 if it is? Not sure we need an API break for this
Couldn't you check if the value is
Duration::MAXand pass -1 if it is? Not sure we need an API break for this
@insearchoflosttime did you get a chance to try @danobi's suggestion with Duration::MAX ?
@anakryiko yes! I will rebase and push it out today.