Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

iv_fd_pump_destroy(3) [debian man page]

iv_fd_pump(3)						    ivykis programmer's manual						     iv_fd_pump(3)

NAME
IV_FD_PUMP_INIT, iv_fd_pump_init, iv_fd_pump_destroy, iv_fd_pump_pump, iv_fd_pump_is_done - pump data between file descriptors SYNOPSIS
#include <iv_fd_pump.h> struct iv_fd_pump { int from_fd; int to_fd; void *cookie; void (*set_bands)(void *cookie, int pollin, int pollout); unsigned int flags; }; void IV_FD_PUMP_INIT(struct iv_fd_pump *this); void iv_fd_pump_init(struct iv_fd_pump *this); void iv_fd_pump_destroy(struct iv_fd_pump *this); int iv_fd_pump_pump(struct iv_fd_pump *this); int iv_fd_pump_is_done(struct iv_fd_pump *this); DESCRIPTION
iv_fd_pump provides a way for moving data between two file descriptors. To set up iv_fd_pump for moving data, call IV_FD_PUMP_INIT on a struct iv_fd_pump object, fill in the ->from_fd, ->to_fd, ->cookie, ->set_bands and ->flags members, and then call iv_fd_pump_init on the object. Conversely, to destroy a struct iv_fd_pump object, call iv_fd_pump_destroy. There are no restrictions on when this function can be called. A call to iv_fd_pump_pump will attempt to move data from ->from_fd to ->to_fd via an internal buffer associated with the struct iv_fd_pump object. During calls to iv_fd_pump_init, iv_fd_pump_destroy and iv_fd_pump_pump, the callback function specified by ->set_bands may be invoked (with ->cookie as its first argument), by which iv_fd_pump indicates under which circumstances it wishes for future invocations of iv_fd_pump_pump to be done. If the pollin argument to ->set_bands is true, there is space left in the internal buffer (and we have not yet seen an end-of-file condi- tion on input), and so you should call iv_fd_pump_pump again when there is a POLLIN condition on ->from_fd. If the pollout argument to ->set_bands is true, there is data in the internal buffer that could not all be transferred to ->to_fd, and so you should call iv_fd_pump_pump again when there is a POLLOUT condition on ->to_fd. If IV_FD_PUMP_FLAG_RELAY_EOF is set in ->flags, iv_fd_pump_pump will call shutdown(2) on ->to_fd with SHUT_WR as its second argument upon seeing an end-of-file condition on ->from_fd (but only after all data from the internal buffer has been drained into ->to_fd first). iv_fd_pump_pump will return -1 if there was an error, 0 if we're done pumping data (meaning that an end-of-file condition was seen on the input file descriptor and that all data in the internal buffer has been drained into the output file descriptor), or 1 if there is more data left to be pumped. iv_fd_pump_is_done will return a true value if iv_fd_pump_pump has previously returned 0, otherwise it will return false. Internally, iv_fd_pump_pump will use splice(2) if it is available, otherwise it will fall back to read(2) and write(2). SEE ALSO
ivykis(3), splice(2) ivykis 2012-06-05 iv_fd_pump(3)

Check Out this Related Man Page

iv_event(3)						    ivykis programmer's manual						       iv_event(3)

NAME
IV_EVENT_INIT, iv_event_register, iv_event_unregister, iv_event_post - manage ivykis objects for event notification SYNOPSIS
#include <iv_event.h> struct iv_event { void *cookie; void (*handler)(void *); }; int IV_EVENT_INIT(struct iv_event *this); int iv_event_register(struct iv_event *this); void iv_event_unregister(struct iv_event *this); void iv_event_post(struct iv_event *this); DESCRIPTION
iv_event provides a way for delivering events to ivykis(3) recipients across thread boundaries. The intended event recipient calls IV_EVENT_INIT on a struct iv_event object, fills in ->cookie and ->handler, and then calls iv_event_reg- ister on the object. To generate an event, call iv_event_post on the previously initialized struct iv_event object. This will cause the callback specified by ->handler to be called in the thread that the struct iv_event object was registered in, with ->cookie as its sole argument. To deinitialize a struct iv_event object, call iv_event_unregister from the same thread that iv_event_register was called from on that object. It is permitted to unregister a struct iv_event object from any ivykis callback function in the thread it was registered in, including from a callback function triggered by this object, and it is permitted to free the memory corresponding to an unregistered object from its own callback function. iv_event_post can be called from the same thread that iv_event_register was called from, or from a different thread within the same process, but can not be called from a different process, and can not be called from signal handlers. If you need this functionality, look at iv_event_raw(3). Internally, iv_event is implemented as a wrapper around iv_event_raw(3), and multiplexes multiple struct iv_event objects over per-thread struct iv_event_raw objects, to save file descriptors and kernel resources. SEE ALSO
ivykis(3), iv_event_raw(3) ivykis 2010-09-03 iv_event(3)
Man Page