当前位置: 首页>>代码示例>>C++>>正文


C++ Connection类代码示例

本文整理汇总了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)");
}
开发者ID:adfin,项目名称:mordor,代码行数:6,代码来源:pq.cpp

示例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;
}
开发者ID:jacktang,项目名称:ClickHouse,代码行数:64,代码来源:MultiplexedConnections.cpp

示例3:

 ~SceneInfo(){
     sigDetachedFromRootConnection.disconnect();
     sigCheckToggledConnection.disconnect();
 }
开发者ID:s-nakaoka,项目名称:choreonoid,代码行数:4,代码来源:SceneView.cpp

示例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
    }
开发者ID:bassosimone,项目名称:measurement-kit,代码行数:29,代码来源:connection_check_fds.cpp

示例5: addWaiting

void ConnectionManager::addWaiting(Connection& conn) {
	std::cout << conn.getAddr_p() << " add to wait" << std::endl;
	waitting_conn.push_back(conn);
}
开发者ID:williamd4112,项目名称:NPP_HW2,代码行数:4,代码来源:connection.cpp

示例6: closed

bool Connection::closed() const
{
  Connection *self = const_cast<Connection *>(this);
  return !self->socket().is_open();
}
开发者ID:LifeGo,项目名称:wt,代码行数:5,代码来源:Connection.C


注:本文中的Connection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。