Version 3.3.0
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.

while (
(ret = conn->async_new_op(conn, "table:async", NULL, &ex_asynckeys.iface, &op)) != 0) {
/*
* If we used up all the handles, pause and retry to give the workers a chance to catch
* up.
*/
fprintf(stderr, "asynchronous operation handle not available\n");
if (ret == EBUSY)
sleep(1);
else
return (EXIT_FAILURE);
}
Examples
ex_async.c.

Member Data Documentation

◆ notify

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 {
uint32_t num_keys;
} ASYNC_KEYS;
static int
async_callback(WT_ASYNC_CALLBACK *cb, WT_ASYNC_OP *op, int wiredtiger_error, uint32_t flags)
{
ASYNC_KEYS *asynckey = (ASYNC_KEYS *)cb;
WT_ITEM k, v;
const char *key, *value;
uint64_t id;
(void)flags; /* Unused */
/* Retrieve the operation's WT_ASYNC_OPTYPE type. */
type = op->get_type(op);
/* Retrieve the operation's 64-bit identifier. */
id = op->get_id(op);
/* Check for a WiredTiger error. */
if (wiredtiger_error != 0) {
fprintf(stderr, "ID %" PRIu64 " error %d: %s\n", id, wiredtiger_error,
wiredtiger_strerror(wiredtiger_error));
global_error = wiredtiger_error;
return (1);
}
/* If doing a search, retrieve the key/value pair. */
if (type == WT_AOP_SEARCH) {
error_check(op->get_key(op, &k));
key = k.data;
error_check(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 (0);
}
WT_ASYNC_OP::get_value
int get_value(WT_ASYNC_OP *op,...)
Invoke the underlying WT_CURSOR::get_value method; see that method for configuration,...
WT_ASYNC_OP::get_key
int get_key(WT_ASYNC_OP *op,...)
Invoke the underlying WT_CURSOR::get_key method; see that method for configuration,...
WT_AOP_SEARCH
@ WT_AOP_SEARCH
WT_ASYNC_OP::search.
Definition: wiredtiger.in:736
WT_ITEM::data
const void * data
The memory reference of the data item.
Definition: wiredtiger.in:111
wiredtiger_strerror
const char * wiredtiger_strerror(int error)
Return information about a WiredTiger error as a string (see WT_SESSION::strerror for a thread-safe A...
WT_ASYNC_OP
A WT_ASYNC_OP handle is the interface to an asynchronous operation.
Definition: wiredtiger.in:761
WT_ITEM
A raw item of data to be managed, including a pointer to the data and a length.
Definition: wiredtiger.in:103
WT_ASYNC_OP::get_type
WT_ASYNC_OPTYPE get_type(WT_ASYNC_OP *op)
Get the type for this operation.
WT_ASYNC_OPTYPE
WT_ASYNC_OPTYPE
Asynchronous operation types.
Definition: wiredtiger.in:731
WT_ASYNC_OP::get_id
uint64_t get_id(WT_ASYNC_OP *op)
Get the unique identifier for this operation.
WT_ASYNC_CALLBACK
The interface implemented by applications to accept notifications of the completion of asynchronous o...
Definition: wiredtiger.in:3140