![]() |
![]() |
![]() |
Camel Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <camel/camel.h> CamelAsyncClosure; CamelAsyncClosure * camel_async_closure_new (void
); GAsyncResult * camel_async_closure_wait (CamelAsyncClosure *closure
); void camel_async_closure_free (CamelAsyncClosure *closure
); void camel_async_closure_callback (GObject *source_object
,GAsyncResult *result
,gpointer closure
);
CamelAsyncClosure provides a simple way to run an asynchronous function synchronously without blocking the current thread.
1) Create a CamelAsyncClosure with camel_async_closure_new()
.
2) Call the asynchronous function passing camel_async_closure_callback()
as the GAsyncReadyCallback argument and the CamelAsyncClosure as the
data argument.
3) Call camel_async_closure_wait()
and collect the GAsyncResult.
4) Call the corresponding asynchronous "finish" function, passing the
GAsyncResult returned by camel_async_closure_wait()
.
5) If needed, repeat steps 2-4 for additional asynchronous functions using the same CamelAsyncClosure.
6) Finally, free the CamelAsyncClosure with camel_async_closure_free()
.
typedef struct _CamelAsyncClosure CamelAsyncClosure;
Contains only private data that should be read and manipulated using the functions below.
Since 3.12
CamelAsyncClosure * camel_async_closure_new (void
);
Creates a new CamelAsyncClosure for use with asynchronous functions.
Returns : |
a new CamelAsyncClosure |
Since 3.12
GAsyncResult * camel_async_closure_wait (CamelAsyncClosure *closure
);
Call this function immediately after starting an asynchronous operation. The function waits for the asynchronous operation to complete and returns its GAsyncResult to be passed to the operation's "finish" function.
This function can be called repeatedly on the same CamelAsyncClosure to easily string together multiple asynchronous operations.
|
a CamelAsyncClosure |
Returns : |
a GAsyncResult which is owned by the closure. [transfer none] |
Since 3.12
void camel_async_closure_free (CamelAsyncClosure *closure
);
Frees the closure
and the resources it holds.
|
a CamelAsyncClosure |
Since 3.12
void camel_async_closure_callback (GObject *source_object
,GAsyncResult *result
,gpointer closure
);
Pass this function as the GAsyncReadyCallback argument of an asynchronous function, and the CamelAsyncClosure as the data argument.
This causes camel_async_closure_wait()
to terminate and return result
.
|
a GObject or NULL
|
|
a GAsyncResult |
|
a CamelAsyncClosure |
Since 3.12