From 8718c78ad0d34741165000fa9a24b18db456f095 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 9 May 2011 02:15:28 +0200 Subject: [PATCH] =?UTF-8?q?oio=5Fasync=20or=20The=20Most=20Half-Assed=20Ap?= =?UTF-8?q?i=20In=20The=20Universe=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (apologies for my rant) --- oio.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/oio.h b/oio.h index d3d2e158e..07f2a7b3b 100644 --- a/oio.h +++ b/oio.h @@ -56,7 +56,9 @@ typedef void (*oio_shutdown_cb)(oio_req_t* req, int status); typedef void (*oio_accept_cb)(oio_handle_t* handle); typedef void (*oio_close_cb)(oio_handle_t* handle, int status); typedef void (*oio_timer_cb)(oio_req_t* req, int64_t skew, int status); +/* TODO: do loop_cb and async_cb really need a status argument? */ typedef void (*oio_loop_cb)(oio_handle_t* handle, int status); +typedef void (*oio_async_cb)(oio_handle_t* handle, int stats); /* Expand this list if necessary. */ @@ -106,7 +108,8 @@ typedef enum { OIO_FILE, OIO_PREPARE, OIO_CHECK, - OIO_IDLE + OIO_IDLE, + OIO_ASYNC } oio_handle_type; typedef enum { @@ -116,7 +119,8 @@ typedef enum { OIO_READ, OIO_WRITE, OIO_SHUTDOWN, - OIO_TIMEOUT + OIO_TIMEOUT, + OIO_WAKEUP } oio_req_type; @@ -238,6 +242,16 @@ int oio_idle_init(oio_handle_t* handle, oio_close_cb close_cb, void* data); int oio_idle_start(oio_handle_t* handle, oio_loop_cb cb); int oio_idle_stop(oio_handle_t* handle); +/* oio_async_send wakes up the event loop and calls the async handle's callback + * There is no guarantee that every oio_async_send call leads to exactly one + * invocation of the callback; The only guarantee is that the callback function + * is called at least once after the call to async_send. Unlike everything + * else, oio_async_send can be called from another thread. + */ +int oio_async_init(oio_handle_t* handle, oio_async_cb async_cb, + oio_close_cb close_cb, void* data); +int oio_async_send(oio_handle_t* handle); + /* Request handle to be closed. close_cb will be called * asynchronously after this call. */