Version 2.2.1
WT_ASYNC_CALLBACK Struct Reference

The interface implemented by applications to accept notifications of the completion of asynchronous operations. More...

Public Attributes

int(* notify )(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *op, int op_ret, uint32_t flags)
 Callback to receive completion notification. More...
 

Detailed Description

The interface implemented by applications to accept notifications of the completion of asynchronous operations.

Applications register their implementation with WiredTiger by calling WT_CONNECTION::async_new_op.

op = NULL;
retry:
ret = wt_conn->async_new_op(wt_conn, uri, NULL,
&ex_asynckeys.iface, &op);
if (ret != 0) {
/*
* If we used up all the ops, pause and retry to
* give the workers a chance to process them.
*/
fprintf(stderr,
"Iteration %d: async_new_op ret %d\n",i,ret);
sleep(1);
goto retry;
}

Member Data Documentation

int(* WT_ASYNC_CALLBACK::notify)(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *op, int op_ret, uint32_t flags)

Callback to receive completion notification.

Parameters
[in]opthe operation handle
[in]op_retthe result of the async operation
[in]flagscurrently unused
Returns
zero for success, non-zero to indicate an error.
typedef struct {
WT_ASYNC_CALLBACK iface;
uint32_t num_keys;
} ASYNC_KEYS;
static int
cb_asyncop(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *op, int ret, uint32_t flags)
{
ASYNC_KEYS *asynckey = (ASYNC_KEYS *)cb;
WT_ITEM k, v;
const char *key, *value;
uint64_t id;
int t_ret;
(void)flags;
type = op->get_type(op);
id = op->get_id(op);
t_ret = 0;
if (ret != 0) {
printf("ID %" PRIu64 " error %d\n", id, ret);
global_error = ret;
return (1);
}
if (type == WT_AOP_SEARCH) {
t_ret = op->get_key(op, &k);
key = k.data;
t_ret = op->get_value(op, &v);
value = v.data;
ATOMIC_ADD(asynckey->num_keys, 1);
printf("Id %" PRIu64 " got record: %s : %s\n", id, key, value);
}
return (t_ret);
}
static ASYNC_KEYS ex_asynckeys = { {cb_asyncop}, 0 };