The function ba_get_next_event() retrieves information about the next event queued in the FIFO buffer. It can be called in either blocking or non-blocking mode:
In blocking mode, ba_get_next_event() waits until there is an event stored in the buffer before returning.
In non-blocking mode, ba_get_next_event() either returns successfully with an event, or, if the buffer is empty, returns -1, sets ba_errno to BA_SYSERR, and errno to EWOULDBLOCK (EAGAIN).