android_looper_sys::ALooper_addFd [] [src]

pub unsafe extern fn ALooper_addFd(looper: *mut ALooper, fd: c_int, ident: c_int, events: c_int, callback: ALooper_callbackFunc, data: *mut c_void) -> c_int

Adds a new file descriptor to be polled by the looper. If the same file descriptor was previously added, it is replaced.

There are two main uses of this function:

(1) If "callback" is non-NULL, then this function will be called when there is data on the file descriptor. It should execute any events it has pending, appropriately reading from the file descriptor. The 'ident' is ignored in this case.

(2) If "callback" is NULL, the 'ident' will be returned by ALooper_pollOnce when its file descriptor has data available, requiring the caller to take care of processing it.

Returns 1 if the file descriptor was added or -1 if an error occurred.

This method can be called on any thread. This method may block briefly if it needs to wake the poll.