本文整理汇总了C++中WT_CONNECTION::async_new_op方法的典型用法代码示例。如果您正苦于以下问题:C++ WT_CONNECTION::async_new_op方法的具体用法?C++ WT_CONNECTION::async_new_op怎么用?C++ WT_CONNECTION::async_new_op使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_CONNECTION
的用法示例。
在下文中一共展示了WT_CONNECTION::async_new_op方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
int
main(void)
{
WT_ASYNC_OP *op;
WT_CONNECTION *conn;
WT_SESSION *session;
int i, ret;
char k[MAX_KEYS][16], v[MAX_KEYS][16];
/*! [async example connection] */
ret = wiredtiger_open(home, NULL,
"create,cache_size=100MB,"
"async=(enabled=true,ops_max=20,threads=2)", &conn);
/*! [async example connection] */
/*! [async example table create] */
ret = conn->open_session(conn, NULL, NULL, &session);
ret = session->create(
session, "table:async", "key_format=S,value_format=S");
/*! [async example table create] */
/* Insert a set of keys asynchronously. */
for (i = 0; i < MAX_KEYS; i++) {
/*! [async handle allocation] */
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 (ret);
}
/*! [async handle allocation] */
/*! [async insert] */
/*
* Set the operation's string key and value, and then do
* an asynchronous insert.
*/
/*! [async set the operation's string key] */
snprintf(k[i], sizeof(k), "key%d", i);
op->set_key(op, k[i]);
/*! [async set the operation's string key] */
/*! [async set the operation's string value] */
snprintf(v[i], sizeof(v), "value%d", i);
op->set_value(op, v[i]);
/*! [async set the operation's string value] */
ret = op->insert(op);
/*! [async insert] */
}
/*! [async flush] */
/* Wait for all outstanding operations to complete. */
ret = conn->async_flush(conn);
/*! [async flush] */
/*! [async compaction] */
/*
* Compact a table asynchronously, limiting the run-time to 5 minutes.
*/
ret = conn->async_new_op(
conn, "table:async", "timeout=300", &ex_asynckeys.iface, &op);
ret = op->compact(op);
/*! [async compaction] */
/* Search for the keys we just inserted, asynchronously. */
for (i = 0; i < MAX_KEYS; i++) {
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 (ret);
}
/*! [async search] */
/*
* Set the operation's string key and value, and then do
* an asynchronous search.
*/
snprintf(k[i], sizeof(k), "key%d", i);
op->set_key(op, k[i]);
op->search(op);
/*! [async search] */
}
/*
//.........这里部分代码省略.........