![]() |
GNUnet
0.11.x
|
Asynchronous operations; register callbacks for operations and call them when a response arrives. More...
#include "gnunet_util_lib.h"
Go to the source code of this file.
Functions | |
struct GNUNET_OP_Handle * | GNUNET_OP_create () |
Create new operations handle. More... | |
void | GNUNET_OP_destroy (struct GNUNET_OP_Handle *h) |
Destroy operations handle. More... | |
uint64_t | GNUNET_OP_get_next_id (struct GNUNET_OP_Handle *h) |
Get a unique operation ID to distinguish between asynchronous requests. More... | |
int | GNUNET_OP_get (struct GNUNET_OP_Handle *h, uint64_t op_id, GNUNET_ResultCallback *result_cb, void **cls, void **ctx) |
Find operation by ID. More... | |
uint64_t | GNUNET_OP_add (struct GNUNET_OP_Handle *h, GNUNET_ResultCallback result_cb, void *cls, void *ctx) |
Add a new operation. More... | |
int | GNUNET_OP_result (struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx) |
Call the result callback of an operation and remove it. More... | |
int | GNUNET_OP_remove (struct GNUNET_OP_Handle *h, uint64_t op_id) |
Remove / cancel an operation. More... | |
Asynchronous operations; register callbacks for operations and call them when a response arrives.
Definition in file gnunet_op_lib.h.
struct GNUNET_OP_Handle* GNUNET_OP_create | ( | ) |
Create new operations handle.
Definition at line 89 of file op.c.
References GNUNET_new.
void GNUNET_OP_destroy | ( | struct GNUNET_OP_Handle * | h | ) |
uint64_t GNUNET_OP_get_next_id | ( | struct GNUNET_OP_Handle * | h | ) |
int GNUNET_OP_get | ( | struct GNUNET_OP_Handle * | h, |
uint64_t | op_id, | ||
GNUNET_ResultCallback * | result_cb, | ||
void ** | cls, | ||
void ** | ctx | ||
) |
Find operation by ID.
h | Operations handle. | |
op_id | Operation ID to look up. | |
[out] | result_cb | If an operation was found, its result callback is returned here. |
[out] | cls | If an operation was found, its closure is returned here. |
[out] | ctx | User context. |
h | Operations handle. | |
op_id | Operation ID to look up. | |
[out] | result_cb | If an operation was found, its result callback is returned here. |
[out] | cls | If an operation was found, its closure is returned here. |
[out] | ctx | If an operation was found, its user context is returned here. |
Definition at line 161 of file op.c.
References OperationListItem::cls, ctx, GNUNET_NO, GNUNET_YES, h, op, op_find(), OperationListItem::op_id, and OperationListItem::result_cb.
uint64_t GNUNET_OP_add | ( | struct GNUNET_OP_Handle * | h, |
GNUNET_ResultCallback | result_cb, | ||
void * | cls, | ||
void * | ctx | ||
) |
Add a new operation.
h | Operations handle. |
result_cb | Function to call with the result of the operation. |
cls | Closure for result_cb. |
ctx | User context. |
Definition at line 198 of file op.c.
References OperationListItem::cls, ctx, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_OP_get_next_id(), h, LOG, op, and OperationListItem::result_cb.
int GNUNET_OP_result | ( | struct GNUNET_OP_Handle * | h, |
uint64_t | op_id, | ||
int64_t | result_code, | ||
const void * | data, | ||
uint16_t | data_size, | ||
void ** | ctx | ||
) |
Call the result callback of an operation and remove it.
h | Operations handle. | |
op_id | Operation ID. | |
result_code | Result of the operation. | |
data | Data result of the operation. | |
data_size | Size of data. | |
[out] | ctx | User context. |
Definition at line 301 of file op.c.
References ctx, data, data_size, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, h, LOG, OperationListItem::op_id, and op_result().
int GNUNET_OP_remove | ( | struct GNUNET_OP_Handle * | h, |
uint64_t | op_id | ||
) |
Remove / cancel an operation.
h | Operations handle. |
op_id | Operation ID. |
Definition at line 327 of file op.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_YES, h, LOG, OperationListItem::op_id, and op_result().