Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ivykis(3) [debian man page]

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

NAME
ivykis - library for asynchronous I/O readiness notification DESCRIPTION
ivykis is a library for asynchronous I/O readiness notification. It is a thin, portable wrapper around OS-provided mechanisms such as epoll_create(2), kqueue(2), poll(2), poll(7d) (/dev/poll), port_create(3C) and select(2). ivykis was mainly designed for building high-performance network applications, but can be used in any event-driven application that uses poll(2)able file descriptors as its event sources. While some programming models dictate using blocking I/O and starting a thread per event source, programs written to the ivykis API are generally single-threaded (or use only a small number of threads), and never block on I/O. All input and output is done in a nonblocking fashion, with I/O readiness notifications delivered via callback functions. The two main event sources in ivykis are file descriptors and timers. File descriptors generate an event when they become readable or writable or trigger an error condition, while timers generate an event when the system time increments past a certain pre-set time. Events associated with file descriptors are level-triggered -- a callback function set up to handle a certain file descriptor event will be called repeatedly until the condition generating the event has been cleared. As mentioned, applications using ivykis are generally single-threaded. Event callbacks are strictly serialised within a thread, and non- preemptible. This mostly removes the need for locking of shared data, and generally simplifies writing applications. Each thread that uses ivykis has its own file descriptors and timers, and runs a separate event loop. In ivykis, all code that is not initialization code runs from callback functions. Callback functions are not allowed to block. If a par- ticular piece of code wants to perform a certain operation that can block, it either has to schedule it to run in a separate thread, or it has to perform the operation in a nonblocking fashion instead. For example, registering an input callback function instead of blocking on a read, registering a timer instead of calling sleep(2), etc. In case of an internal error, ivykis will use iv_fatal(3) to report the error. The application can provide a custom fatal error handler by calling iv_set_fatal_msg_handler(3). SEE ALSO
iv_examples(3), iv_fatal(3), iv_fd(3), iv_timer(3), iv_task(3), iv_init(3), iv_main(3), iv_time(3) ivykis 2010-08-15 ivykis(3)

Check Out this Related Man Page

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

NAME
iv_task_register, iv_task_unregister, iv_task_registered - deal with ivykis tasks SYNOPSIS
#include <iv.h> struct iv_task { void *cookie; void (*handler)(void *); }; void IV_TASK_INIT(struct iv_task *task); void iv_task_register(struct iv_task *task); void iv_task_unregister(struct iv_task *task); int iv_task_registered(struct iv_task *task); DESCRIPTION
The functions iv_task_register and iv_task_unregister register, respectively unregister, a task with the current thread's ivykis event loop. iv_task_registered on a task returns true if that task is currently registered with ivykis. A task is like a timer, but with an immediate timeout. When a task is registered, unless it is unregistered again first, the callback function specified by ->handler is guaranteed to be called once, in the thread that the task was registered in, some time after control returns to the ivykis main loop but before ivykis will sleep for more events, with ->cookie as its first and sole argument. When this hap- pens, the task is transparently unregistered. Tasks are mainly used for scheduling code for execution where it is not appropriate to directly run that code in the calling context (for example, because the current context might be run as a callback function where the caller expects certain conditions to remain invariant after the callback completes). The application is allowed to change the ->cookie and ->handler members at any time. A given struct iv_task can only be registered in one thread at a time, and a task can only be unregistered in the thread that it was regis- tered from. There is no limit on the number of tasks registered at once. See iv_examples(3) for programming examples. SEE ALSO
ivykis(3), iv_examples(3) ivykis 2010-08-15 iv_task(3)
Man Page