X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcasync.h;h=6e7469839e8ea06dfd953ee43fd89831295fdbf4;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hp=2853e9c3d0f02ab79cb3acea7d88f7ed8a924219;hpb=c1c904ec2af21f1c2b272d790b38d93824af5352;p=silc.git diff --git a/lib/silcutil/silcasync.h b/lib/silcutil/silcasync.h index 2853e9c3..6e746983 100644 --- a/lib/silcutil/silcasync.h +++ b/lib/silcutil/silcasync.h @@ -35,6 +35,32 @@ * operation, no callback function will be called back to the upper layer. * This must be remembered when implementing the operation layer. * + * EXAMPLE + * + * SilcAsyncOperation async_call(Callback callback, void *cb_context) + * { + * SilcAsyncOperation op; + * OpContext ctx; + * + * // Allocate async operation so that caller can control us, like abort + * op = silc_async_alloc(async_call_abort, NULL, ctx); + * ctx->callback = callback; + * + * ... + * + * // Return async operation for upper layer + * return op; + * } + * + * // This callback is called when silc_async_abort is called by upper layer. + * // The callback given to async_call must not be called after this. + * void async_call_abort(SilcAsyncOperation op, void *context) + * { + * OpContext ctx = context; + * ctx->aborted = TRUE; + * ctx->callback = NULL; + * } + * ***/ #ifndef SILCASYNC_H @@ -252,7 +278,7 @@ SilcAsyncOperation silc_async_alloc(SilcAsyncOperationAbort abort_cb, * silc_async_abort. Since this use pre-allocated context, the function * silc_async_free need not be called. This function is equivalent * to silc_async_alloc except this does not allocate any memory. The `op' - * needs not be uninitialized. + * needs not be uninitialized. This returns always TRUE. * * If the `pause_cb' is provided then the upper layer may also halt and * then later resume the execution of the operation, by calling the