本文整理汇总了C++中Connection类的典型用法代码示例。如果您正苦于以下问题:C++ Connection类的具体用法?C++ Connection怎么用?C++ Connection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Connection类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillUsers
void fillUsers(Connection &conn)
{
conn.execute("CREATE TEMPORARY TABLE users (id INTEGER, name TEXT, height SMALLINT, awesome BOOLEAN, company TEXT, gender CHAR, efficiency REAL, crazy DOUBLE PRECISION, sometime TIMESTAMP)");
conn.execute("INSERT INTO users VALUES (1, 'cody', 72, true, 'Mozy', 'M', .9, .75, '2009-05-19 15:53:45.123456')");
conn.execute("INSERT INTO users VALUES (2, 'brian', 70, false, NULL, 'M', .9, .25, NULL)");
}
示例2: lock
void MultiplexedConnections::sendQuery(
const String & query,
const String & query_id,
UInt64 stage,
const ClientInfo * client_info,
bool with_pending_data)
{
std::lock_guard<std::mutex> lock(cancel_mutex);
if (sent_query)
throw Exception("Query already sent.", ErrorCodes::LOGICAL_ERROR);
if (supports_parallel_execution)
{
if (settings == nullptr)
{
/// Каждый шард имеет один адрес.
auto it = connections.begin();
for (size_t i = 0; i < shard_states.size(); ++i)
{
Connection * connection = *it;
if (connection == nullptr)
throw Exception("MultiplexedConnections: Internal error", ErrorCodes::LOGICAL_ERROR);
connection->sendQuery(query, query_id, stage, nullptr, client_info, with_pending_data);
++it;
}
}
else
{
/// Каждый шард имеет одну или несколько реплик.
auto it = connections.begin();
for (const auto & shard_state : shard_states)
{
Settings query_settings = *settings;
query_settings.parallel_replicas_count = shard_state.active_connection_count;
UInt64 offset = 0;
for (size_t i = 0; i < shard_state.allocated_connection_count; ++i)
{
Connection * connection = *it;
if (connection == nullptr)
throw Exception("MultiplexedConnections: Internal error", ErrorCodes::LOGICAL_ERROR);
query_settings.parallel_replica_offset = offset;
connection->sendQuery(query, query_id, stage, &query_settings, client_info, with_pending_data);
++offset;
++it;
}
}
}
}
else
{
Connection * connection = connections[0];
if (connection == nullptr)
throw Exception("MultiplexedConnections: Internal error", ErrorCodes::LOGICAL_ERROR);
connection->sendQuery(query, query_id, stage, settings, client_info, with_pending_data);
}
sent_query = true;
}
示例3:
~SceneInfo(){
sigDetachedFromRootConnection.disconnect();
sigCheckToggledConnection.disconnect();
}
示例4: TEST_CASE
#include <measurement_kit/common.hpp>
#include <measurement_kit/net.hpp>
#include "src/net/connection.hpp"
using namespace mk;
using namespace mk::net;
TEST_CASE("Ensure that the constructor socket-validity checks work") {
SECTION("Invalid values are properly normalized") {
{
/* Common for both Unix and Windows */
Connection conn(-1);
REQUIRE(conn.get_fileno() == -1);
}
#ifndef WIN32
{
Connection conn(-2);
REQUIRE(conn.get_fileno() == -1);
}
/* ... */
{
Connection conn(INT_MIN);
REQUIRE(conn.get_fileno() == -1);
}
#endif
}
示例5: addWaiting
void ConnectionManager::addWaiting(Connection& conn) {
std::cout << conn.getAddr_p() << " add to wait" << std::endl;
waitting_conn.push_back(conn);
}
示例6: closed
bool Connection::closed() const
{
Connection *self = const_cast<Connection *>(this);
return !self->socket().is_open();
}