本文整理汇总了C++中session::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ session::clone方法的具体用法?C++ session::clone怎么用?C++ session::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类session
的用法示例。
在下文中一共展示了session::clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_direct_backend
static void test_direct_backend(session &sess)
{
const key id = std::string("direct-backend-test");
sess.set_groups({ 0 });
const std::string first_str = "first-data";
const std::string second_str = "second-data";
server_node &node = global_data->nodes.front();
session first = sess.clone();
first.set_direct_id(node.remote(), 0);
session second = sess.clone();
second.set_direct_id(node.remote(), 3);
ELLIPTICS_REQUIRE(async_first_write, first.write_data(id, first_str, 0));
ELLIPTICS_REQUIRE(async_second_write, second.write_data(id, second_str, 0));
ELLIPTICS_REQUIRE(async_first_read, first.read_data(id, 0, 0));
read_result_entry first_read = async_first_read.get_one();
BOOST_REQUIRE_EQUAL(first_read.file().to_string(), first_str);
BOOST_REQUIRE_EQUAL(first_read.command()->backend_id, 0);
ELLIPTICS_REQUIRE(async_second_read, second.read_data(id, 0, 0));
read_result_entry second_read = async_second_read.get_one();
BOOST_REQUIRE_EQUAL(second_read.file().to_string(), second_str);
BOOST_REQUIRE_EQUAL(second_read.command()->backend_id, 3);
}
示例2: test_make_backend_readonly
static void test_make_backend_readonly(session &sess)
{
server_node &node = global_data->nodes.back();
const key id = std::string("read_only_key");
const std::string data = "read_only_data";
ELLIPTICS_REQUIRE(async_readonly_result, sess.make_readonly(node.remote(), 4));
backend_status_result_entry result = async_readonly_result.get_one();
BOOST_REQUIRE(result.is_valid());
BOOST_REQUIRE_EQUAL(result.count(), 1);
dnet_backend_status *status = result.backend(0);
BOOST_REQUIRE_EQUAL(status->backend_id, 4);
BOOST_REQUIRE_EQUAL(status->read_only, true);
session new_sess = sess.clone();
new_sess.set_direct_id(node.remote(), 4);
ELLIPTICS_REQUIRE_ERROR(write_result, new_sess.write_data(id, data, 0), -EROFS);
ELLIPTICS_REQUIRE_ERROR(second_async_readonly_result, sess.make_readonly(node.remote(), 4), -EALREADY);
}