jpayne@69: /* jpayne@69: * Copyright 2011 Red Hat, Inc. jpayne@69: * jpayne@69: * Permission is hereby granted, free of charge, to any person jpayne@69: * obtaining a copy of this software and associated documentation files jpayne@69: * (the "Software"), to deal in the Software without restriction, jpayne@69: * including without limitation the rights to use, copy, modify, merge, jpayne@69: * publish, distribute, sublicense, and/or sell copies of the Software, jpayne@69: * and to permit persons to whom the Software is furnished to do so, jpayne@69: * subject to the following conditions: jpayne@69: * jpayne@69: * The above copyright notice and this permission notice shall be jpayne@69: * included in all copies or substantial portions of the Software. jpayne@69: * jpayne@69: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, jpayne@69: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF jpayne@69: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND jpayne@69: * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS jpayne@69: * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN jpayne@69: * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN jpayne@69: * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE jpayne@69: * SOFTWARE. jpayne@69: */ jpayne@69: jpayne@69: #ifndef VERTO_H_ jpayne@69: #define VERTO_H_ jpayne@69: jpayne@69: #include /* For time_t */ jpayne@69: #include /* For pid_t */ jpayne@69: jpayne@69: #ifdef WIN32 jpayne@69: #include jpayne@69: typedef HANDLE verto_proc; jpayne@69: typedef DWORD verto_proc_status; jpayne@69: #else jpayne@69: #include jpayne@69: typedef pid_t verto_proc; jpayne@69: typedef int verto_proc_status; jpayne@69: #endif jpayne@69: jpayne@69: #define VERTO_SIG_IGN ((verto_callback *) 1) jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" jpayne@69: { jpayne@69: #endif /* __cplusplus */ jpayne@69: jpayne@69: typedef struct verto_ctx verto_ctx; jpayne@69: typedef struct verto_ev verto_ev; jpayne@69: jpayne@69: typedef enum { jpayne@69: VERTO_EV_TYPE_NONE = 0, jpayne@69: VERTO_EV_TYPE_IO = 1, jpayne@69: VERTO_EV_TYPE_TIMEOUT = 1 << 1, jpayne@69: VERTO_EV_TYPE_IDLE = 1 << 2, jpayne@69: VERTO_EV_TYPE_SIGNAL = 1 << 3, jpayne@69: VERTO_EV_TYPE_CHILD = 1 << 4 jpayne@69: } verto_ev_type; jpayne@69: jpayne@69: typedef enum { jpayne@69: VERTO_EV_FLAG_NONE = 0, jpayne@69: VERTO_EV_FLAG_PERSIST = 1, jpayne@69: VERTO_EV_FLAG_PRIORITY_LOW = 1 << 1, jpayne@69: VERTO_EV_FLAG_PRIORITY_MEDIUM = 1 << 2, jpayne@69: VERTO_EV_FLAG_PRIORITY_HIGH = 1 << 3, jpayne@69: VERTO_EV_FLAG_IO_READ = 1 << 4, jpayne@69: VERTO_EV_FLAG_IO_WRITE = 1 << 5, jpayne@69: VERTO_EV_FLAG_IO_ERROR = 1 << 7, jpayne@69: VERTO_EV_FLAG_IO_CLOSE_FD = 1 << 8, jpayne@69: VERTO_EV_FLAG_REINITIABLE = 1 << 6, jpayne@69: _VERTO_EV_FLAG_MUTABLE_MASK = VERTO_EV_FLAG_PRIORITY_LOW jpayne@69: | VERTO_EV_FLAG_PRIORITY_MEDIUM jpayne@69: | VERTO_EV_FLAG_PRIORITY_HIGH jpayne@69: | VERTO_EV_FLAG_IO_READ jpayne@69: | VERTO_EV_FLAG_IO_WRITE, jpayne@69: _VERTO_EV_FLAG_MAX = VERTO_EV_FLAG_IO_CLOSE_FD jpayne@69: } verto_ev_flag; jpayne@69: jpayne@69: typedef void (verto_callback)(verto_ctx *ctx, verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Creates a new event context using an optionally specified implementation jpayne@69: * and/or optionally specified required features. jpayne@69: * jpayne@69: * If you are an application that has already decided on using a particular jpayne@69: * event loop implementation, you should not call this function, but instead jpayne@69: * import the verto-NAME.h header and link against the verto-NAME.so, where jpayne@69: * NAME is the implementation you wish to use. jpayne@69: * jpayne@69: * If you are a library, you should generally avoid creating event contexts jpayne@69: * on your own but allow applications to pass in a verto_ctx you can use. jpayne@69: * jpayne@69: * There are two cases where you should use this function. The first is jpayne@69: * where you have a need to choose an implementation at run time, usually jpayne@69: * for testing purposes. The second and more common is when you simply jpayne@69: * wish to remain implementation agnostic. In this later case, you should jpayne@69: * always call like this: verto_new(NULL, ...). This lets verto choose the best jpayne@69: * implementation to use. jpayne@69: * jpayne@69: * If impl is not NULL, a new context is returned which is backed by the jpayne@69: * implementation specified. If the implementation specified is not jpayne@69: * available or if the required types (reqtypes) are not provided by the jpayne@69: * named implementation, NULL is returned. The parameter 'impl' can specify: jpayne@69: * * The full path to an implementation library jpayne@69: * * The name of the implementation library (i.e. - "glib" or "libev") jpayne@69: * jpayne@69: * If impl is NULL, verto will attempt to automatically determine the jpayne@69: * best implementation to use. jpayne@69: * jpayne@69: * First, verto will attempt to use an existing, previously loaded jpayne@69: * implementation. This is handled automatically by internal caching of either jpayne@69: * the first implementation loaded or the one specified by verto_set_default(). jpayne@69: * jpayne@69: * Second, verto will attempt to discern if you are already linked to any jpayne@69: * of the supported implementations (to avoid wasting memory by loading jpayne@69: * extra unnecessary libraries). If you are linked to one supported jpayne@69: * implementation, that implementation will be chosen. If you are linked jpayne@69: * to more than one supported implementation one of the ones linked to jpayne@69: * will be chosen, but the order of the particular choice is undefined. jpayne@69: * jpayne@69: * Third, verto will attempt to load the compile-time default, if defined at jpayne@69: * build time and available at runtime. jpayne@69: * jpayne@69: * Last, verto will attempt to load any implementation installed. The specific jpayne@69: * order of this step is undefined. jpayne@69: * jpayne@69: * In all cases above, if the implementation does not support all the specified jpayne@69: * features (reqtypes), it will be skipped and processing will continue from jpayne@69: * where it left off. This means that if verto_new() returns non-NULL it is jpayne@69: * guaranteed to support the features you specified. jpayne@69: * jpayne@69: * @see verto_set_default() jpayne@69: * @param impl The implementation to use, or NULL. jpayne@69: * @param reqtypes A bitwise or'd list of required event type features. jpayne@69: * @return A new verto_ctx, or NULL on error. Call verto_free() when done. jpayne@69: */ jpayne@69: verto_ctx * jpayne@69: verto_new(const char *impl, verto_ev_type reqtypes); jpayne@69: jpayne@69: /** jpayne@69: * Gets the default event context using an optionally specified implementation. jpayne@69: * jpayne@69: * This function is essentially a singleton version of verto_new(). However, jpayne@69: * since this function must return the same loop as the *_default() call of jpayne@69: * the underlying implementation (if such a function exists), it is NOT a jpayne@69: * global singleton, but a per-implementation singleton. For this reason, you jpayne@69: * must call verto_free() when you are done with this loop. Even after calling jpayne@69: * verto_free() on the default verto_ctx, you can safely call verto_default() jpayne@69: * again and receive a new reference to the same (internally default) loop. jpayne@69: * jpayne@69: * In all other respects, verto_default() acts exactly like verto_new(). jpayne@69: * jpayne@69: * @see verto_new() jpayne@69: * @see verto_free() jpayne@69: * @param impl The implementation to use, or NULL. jpayne@69: * @param reqtypes A bitwise or'd list of required event type features. jpayne@69: * @return The default verto_ctx, or NULL on error. Call verto_free() when done. jpayne@69: */ jpayne@69: verto_ctx * jpayne@69: verto_default(const char *impl, verto_ev_type reqtypes); jpayne@69: jpayne@69: /** jpayne@69: * Sets the default implementation to use by its name. jpayne@69: * jpayne@69: * This function returns 1 on success and 0 on failure. It can fail for the jpayne@69: * following reasons: jpayne@69: * 1. The default implementation was already set via verto_set_default(). jpayne@69: * 2. The implementation specified could not be found. jpayne@69: * 3. The implementation specified didn't support the features specified. jpayne@69: * 4. The impl argument was NULL. jpayne@69: * 5. verto_new() was already called. jpayne@69: * 6. verto_default() was already called. jpayne@69: * 7. verto_new_NAME() was already called. jpayne@69: * 8. verto_default_NAME() was already called. jpayne@69: * 9. verto_convert_NAME() was already called. jpayne@69: * jpayne@69: * @see verto_new() jpayne@69: * @see verto_default() jpayne@69: * @param impl The implementation to use. jpayne@69: * @param reqtypes A bitwise or'd list of required event type features. jpayne@69: * @return The default verto_ctx, or NULL on error. Call verto_free() when done. jpayne@69: */ jpayne@69: int jpayne@69: verto_set_default(const char *impl, verto_ev_type reqtypes); jpayne@69: jpayne@69: /** jpayne@69: * Sets the allocator to use for verto_ctx and verto_ev objects. jpayne@69: * jpayne@69: * If you plan to set the allocator, you MUST call this function before any jpayne@69: * other verto_*() calls. jpayne@69: * jpayne@69: * @see verto_new() jpayne@69: * @see verto_default() jpayne@69: * @see verto_add_io() jpayne@69: * @see verto_add_timeout() jpayne@69: * @see verto_add_idle() jpayne@69: * @see verto_add_signal() jpayne@69: * @see verto_add_child() jpayne@69: * @param resize The allocator to use (behaves like realloc(); jpayne@69: * resize(ptr, 0) must free memory at ptr.) jpayne@69: * @param hierarchical Zero if the allocator is not hierarchical jpayne@69: */ jpayne@69: int jpayne@69: verto_set_allocator(void *(*resize)(void *mem, size_t size), int hierarchical); jpayne@69: jpayne@69: /** jpayne@69: * Frees a verto_ctx. jpayne@69: * jpayne@69: * When called on a default verto_ctx, the reference will be freed but the jpayne@69: * internal default loop will still be available via another call to jpayne@69: * verto_default(). jpayne@69: * jpayne@69: * @see verto_new() jpayne@69: * @see verto_default() jpayne@69: * @param ctx The verto_ctx to free. jpayne@69: */ jpayne@69: void jpayne@69: verto_free(verto_ctx *ctx); jpayne@69: jpayne@69: /** jpayne@69: * Frees global state. jpayne@69: * jpayne@69: * Remove and free all allocated global state. Call only when no further jpayne@69: * contexts exist and all threads have exited. jpayne@69: * jpayne@69: * @see verto_new() jpayne@69: * @see verto_free() jpayne@69: * @see verto_default() jpayne@69: */ jpayne@69: void jpayne@69: verto_cleanup(void); jpayne@69: jpayne@69: /** jpayne@69: * Run the verto_ctx forever, or at least until verto_break() is called. jpayne@69: * jpayne@69: * @see verto_break() jpayne@69: * @param ctx The verto_ctx to run. jpayne@69: */ jpayne@69: void jpayne@69: verto_run(verto_ctx *ctx); jpayne@69: jpayne@69: /** jpayne@69: * Run the verto_ctx once. May block. jpayne@69: * jpayne@69: * @param ctx The verto_ctx to run once. jpayne@69: */ jpayne@69: void jpayne@69: verto_run_once(verto_ctx *ctx); jpayne@69: jpayne@69: /** jpayne@69: * Exits the currently running verto_ctx. jpayne@69: * jpayne@69: * @see verto_run() jpayne@69: * @param ctx The verto_ctx to exit. jpayne@69: */ jpayne@69: void jpayne@69: verto_break(verto_ctx *ctx); jpayne@69: jpayne@69: /** jpayne@69: * Re-initializes the verto_ctx. jpayne@69: * jpayne@69: * This function deletes all events, except those which have set the jpayne@69: * VERTO_EV_FLAG_REINITIABLE flag. If you fork(), you MUST call this in the jpayne@69: * child process after the fork! jpayne@69: * jpayne@69: * If this function fails it indicates that at least one jpayne@69: * VERTO_EV_FLAG_REINITIABLE event was not rearmed or that ctx was NULL. jpayne@69: * jpayne@69: * @see verto_new() jpayne@69: * @see verto_default() jpayne@69: * @param ctx The verto_ctx to re-initialize. jpayne@69: * @return Non-zero on success, 0 on error. jpayne@69: */ jpayne@69: int jpayne@69: verto_reinitialize(verto_ctx *ctx); jpayne@69: jpayne@69: /** jpayne@69: * Adds a callback executed when a file descriptor is ready to be read/written. jpayne@69: * jpayne@69: * All verto_ev events are automatically freed when their parent verto_ctx is jpayne@69: * freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is jpayne@69: * provided, the event will repeat until verto_del() is called. If jpayne@69: * VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically jpayne@69: * after its execution. In either case, you may call verto_del() at any time jpayne@69: * to prevent the event from executing. jpayne@69: * If VERTO_EV_FLAG_IO_CLOSE_FD is provided the passed in fd is automatically jpayne@69: * closed when the event is freed with verto_del() jpayne@69: * jpayne@69: * NOTE: On Windows, the underlying select() only works with sockets. As such, jpayne@69: * any attempt to add a non-socket io event on Windows will produce undefined jpayne@69: * results and may even crash. jpayne@69: * jpayne@69: * @see verto_del() jpayne@69: * @param ctx The verto_ctx which will fire the callback. jpayne@69: * @param flags The flags to set (at least one VERTO_EV_FLAG_IO* required). jpayne@69: * @param callback The callback to fire. jpayne@69: * @param fd The file descriptor to watch for reads. jpayne@69: * @return The verto_ev registered with the event context or NULL on error. jpayne@69: */ jpayne@69: verto_ev * jpayne@69: verto_add_io(verto_ctx *ctx, verto_ev_flag flags, jpayne@69: verto_callback *callback, int fd); jpayne@69: jpayne@69: /** jpayne@69: * Adds a callback executed after a period of time. jpayne@69: * jpayne@69: * All verto_ev events are automatically freed when their parent verto_ctx is jpayne@69: * freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is jpayne@69: * provided, the event will repeat until verto_del() is called. If jpayne@69: * VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically jpayne@69: * after its execution. In either case, you may call verto_del() at any time jpayne@69: * to prevent the event from executing. jpayne@69: * jpayne@69: * @see verto_del() jpayne@69: * @param ctx The verto_ctx which will fire the callback. jpayne@69: * @param flags The flags to set. jpayne@69: * @param callback The callback to fire. jpayne@69: * @param interval Time period to wait before firing (in milliseconds). jpayne@69: * @return The verto_ev registered with the event context. jpayne@69: */ jpayne@69: verto_ev * jpayne@69: verto_add_timeout(verto_ctx *ctx, verto_ev_flag flags, jpayne@69: verto_callback *callback, time_t interval); jpayne@69: jpayne@69: /** jpayne@69: * Adds a callback executed when there is nothing else to do. jpayne@69: * jpayne@69: * All verto_ev events are automatically freed when their parent verto_ctx is jpayne@69: * freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is jpayne@69: * provided, the event will repeat until verto_del() is called. If jpayne@69: * VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically jpayne@69: * after its execution. In either case, you may call verto_del() at any time jpayne@69: * to prevent the event from executing. jpayne@69: * jpayne@69: * @see verto_del() jpayne@69: * @param ctx The verto_ctx which will fire the callback. jpayne@69: * @param flags The flags to set. jpayne@69: * @param callback The callback to fire. jpayne@69: * @return The verto_ev registered with the event context. jpayne@69: */ jpayne@69: verto_ev * jpayne@69: verto_add_idle(verto_ctx *ctx, verto_ev_flag flags, jpayne@69: verto_callback *callback); jpayne@69: jpayne@69: /** jpayne@69: * Adds a callback executed when a signal is received. jpayne@69: * jpayne@69: * All verto_ev events are automatically freed when their parent verto_ctx is jpayne@69: * freed. You do not need to free them manually. If VERTO_EV_FLAG_PERSIST is jpayne@69: * provided, the event will repeat until verto_del() is called. If jpayne@69: * VERTO_EV_FLAG_PERSIST is not provided, the event will be freed automatically jpayne@69: * after its execution. In either case, you may call verto_del() at any time jpayne@69: * to prevent the event from executing. jpayne@69: * jpayne@69: * NOTE: If you attempt to ignore a signal without the VERTO_EV_FLAG_PERSIST jpayne@69: * flag, this function fails. jpayne@69: * jpayne@69: * NOTE: SIGCHLD is expressly not supported. If you want this notification, jpayne@69: * please use verto_add_child(). jpayne@69: * jpayne@69: * WARNNIG: Signal events can only be reliably received in the default verto_ctx jpayne@69: * in some implementations. Attempting to receive signal events in non-default jpayne@69: * loops may result in assert() failures. jpayne@69: * jpayne@69: * WARNING: While verto does its best to protect you from crashes, there is jpayne@69: * essentially no way to do signal events if you mix multiple implementations in jpayne@69: * a single process. Attempting to do so will result in undefined behavior, jpayne@69: * and potentially even a crash. You have been warned. jpayne@69: * jpayne@69: * @see verto_add_child() jpayne@69: * @see verto_repeat() jpayne@69: * @see verto_del() jpayne@69: * @param ctx The verto_ctx which will fire the callback. jpayne@69: * @param flags The flags to set. jpayne@69: * @param callback The callback to fire. jpayne@69: * @param signal The signal to watch for. jpayne@69: * @return The verto_ev registered with the event context. jpayne@69: */ jpayne@69: verto_ev * jpayne@69: verto_add_signal(verto_ctx *ctx, verto_ev_flag flags, jpayne@69: verto_callback *callback, int signal); jpayne@69: jpayne@69: /** jpayne@69: * Adds a callback executed when a child process exits. jpayne@69: * jpayne@69: * This event will be freed automatically after its execution. Due to the jpayne@69: * nature of a process' life-cycle, child events cannot persist (processes only jpayne@69: * exit once). This function returns NULL if you attempt to use jpayne@69: * VERTO_EV_FLAG_PERSIST. You may, of course, call verto_del() at any time to jpayne@69: * prevent the callback from firing. jpayne@69: * jpayne@69: * @see verto_del() jpayne@69: * @param ctx The verto_ctx which will fire the callback. jpayne@69: * @param flags The flags to set. jpayne@69: * @param callback The callback to fire. jpayne@69: * @param child The pid (POSIX) or handle (Win32) of the child to watch for. jpayne@69: * @return The verto_ev registered with the event context. jpayne@69: */ jpayne@69: verto_ev * jpayne@69: verto_add_child(verto_ctx *ctx, verto_ev_flag flags, jpayne@69: verto_callback *callback, verto_proc proc); jpayne@69: jpayne@69: /** jpayne@69: * Sets the private pointer of the verto_ev. jpayne@69: * jpayne@69: * The free callback will be called in two cases: jpayne@69: * 1. When the event is deleted (manually or automatically) jpayne@69: * 2. When verto_set_private() is called again, unless jpayne@69: * free is NULL. jpayne@69: * jpayne@69: * @see verto_get_private() jpayne@69: * @param ev The verto_ev jpayne@69: * @param priv The private value to store jpayne@69: * @param free The callback used to free the data or NULL jpayne@69: */ jpayne@69: void jpayne@69: verto_set_private(verto_ev *ev, void *priv, verto_callback *free); jpayne@69: jpayne@69: /** jpayne@69: * Gets the private pointer of the verto_ev. jpayne@69: * jpayne@69: * @see verto_set_private() jpayne@69: * @param ev The verto_ev jpayne@69: * @return The verto_ev private pointer jpayne@69: */ jpayne@69: void * jpayne@69: verto_get_private(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the type of the verto_ev. jpayne@69: * jpayne@69: * @see verto_add_io() jpayne@69: * @see verto_add_timeout() jpayne@69: * @see verto_add_idle() jpayne@69: * @see verto_add_signal() jpayne@69: * @see verto_add_child() jpayne@69: * @param ev The verto_ev jpayne@69: * @return The verto_ev type jpayne@69: */ jpayne@69: verto_ev_type jpayne@69: verto_get_type(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the flags associated with the given verto_ev. jpayne@69: * jpayne@69: * @see verto_add_io() jpayne@69: * @see verto_add_timeout() jpayne@69: * @see verto_add_idle() jpayne@69: * @see verto_add_signal() jpayne@69: * @see verto_add_child() jpayne@69: * @see verto_set_flags() jpayne@69: * @param ev The verto_ev jpayne@69: * @return The verto_ev type jpayne@69: */ jpayne@69: verto_ev_flag jpayne@69: verto_get_flags(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Sets the flags associated with the given verto_ev. jpayne@69: * jpayne@69: * See _VERTO_EV_FLAG_MUTABLE_MASK for the flags that can be changed jpayne@69: * with this function. All others will be ignored. If the flags specified jpayne@69: * are the same as the flags the event already has, this function is a no-op. jpayne@69: * jpayne@69: * @see verto_add_io() jpayne@69: * @see verto_add_timeout() jpayne@69: * @see verto_add_idle() jpayne@69: * @see verto_add_signal() jpayne@69: * @see verto_add_child() jpayne@69: * @see verto_get_flags() jpayne@69: * @param ev The verto_ev jpayne@69: * @param flags The flags for the event jpayne@69: */ jpayne@69: void jpayne@69: verto_set_flags(verto_ev *ev, verto_ev_flag flags); jpayne@69: jpayne@69: /** jpayne@69: * Gets the file descriptor associated with a read/write verto_ev. jpayne@69: * jpayne@69: * @see verto_add_io() jpayne@69: * @param ev The verto_ev to retrieve the file descriptor from. jpayne@69: * @return The file descriptor, or -1 if not a read/write event. jpayne@69: */ jpayne@69: int jpayne@69: verto_get_fd(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the file descriptor state from when the event fires. jpayne@69: * jpayne@69: * @see verto_add_io() jpayne@69: * @param ev The verto_ev to retrieve the fd state from. jpayne@69: * @return The fd state. jpayne@69: */ jpayne@69: verto_ev_flag jpayne@69: verto_get_fd_state(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the interval associated with a timeout verto_ev. jpayne@69: * jpayne@69: * @see verto_add_timeout() jpayne@69: * @param ev The verto_ev to retrieve the interval from. jpayne@69: * @return The interval, or 0 if not a timeout event. jpayne@69: */ jpayne@69: time_t jpayne@69: verto_get_interval(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the signal associated with a signal verto_ev. jpayne@69: * jpayne@69: * @see verto_add_signal() jpayne@69: * @param ev The verto_ev to retrieve the signal from. jpayne@69: * @return The signal, or -1 if not a signal event. jpayne@69: */ jpayne@69: int jpayne@69: verto_get_signal(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the process associated with a child verto_ev. jpayne@69: * jpayne@69: * @see verto_add_child() jpayne@69: * @param ev The verto_ev to retrieve the process from. jpayne@69: * @return The pid/handle, or 0/NULL if not a child event (POSIX/Win32). jpayne@69: */ jpayne@69: verto_proc jpayne@69: verto_get_proc(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the status of the process which caused this event to fire. jpayne@69: * jpayne@69: * @see verto_add_child() jpayne@69: * @param ev The verto_ev to retrieve the status from. jpayne@69: * @return The pid/handle status. jpayne@69: */ jpayne@69: verto_proc_status jpayne@69: verto_get_proc_status(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Gets the verto_ctx associated with a verto_ev. jpayne@69: * jpayne@69: * This is a borrowed reference, don't attempt to free it! jpayne@69: * jpayne@69: * @param ev The verto_ev to retrieve the verto_ctx from. jpayne@69: * @return The verto_ctx. jpayne@69: */ jpayne@69: verto_ctx * jpayne@69: verto_get_ctx(const verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Removes an event from from the event context and frees it. jpayne@69: * jpayne@69: * The event and its contents cannot be used after this call. jpayne@69: * jpayne@69: * @see verto_add_io() jpayne@69: * @see verto_add_timeout() jpayne@69: * @see verto_add_idle() jpayne@69: * @see verto_add_signal() jpayne@69: * @see verto_add_child() jpayne@69: * @param ev The event to delete. jpayne@69: */ jpayne@69: void jpayne@69: verto_del(verto_ev *ev); jpayne@69: jpayne@69: /** jpayne@69: * Returns the event types supported by this implementation. jpayne@69: * jpayne@69: * @param ctx The verto_ctx to query. jpayne@69: * @return The event types supported. jpayne@69: */ jpayne@69: verto_ev_type jpayne@69: verto_get_supported_types(verto_ctx *ctx); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } /* extern "C" */ jpayne@69: #endif /* __cplusplus */ jpayne@69: #endif /* VERTO_H_ */