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


C++ ConnectionPtr::reset方法代码示例

本文整理汇总了C++中ConnectionPtr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::reset方法的具体用法?C++ ConnectionPtr::reset怎么用?C++ ConnectionPtr::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectionPtr的用法示例。


在下文中一共展示了ConnectionPtr::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getOrCreateConnection

 ConnectionPtr SmartSocket::getOrCreateConnection(const udp::endpoint& remote)
 {
     ConnectionPtr conn;
     if (!m_connections.find(remote, conn))
     {
         conn.reset(new Connection(*this, remote));
         m_connections.insert(remote, conn);
     }
     return conn;
 }
开发者ID:AKatti,项目名称:netbase,代码行数:10,代码来源:smart_socket.cpp

示例2: runWTTT

// per page tests
void runWTTT(scriptid_t scriptID, unsigned int shardNumber, const char* runNo, long batchID, bool wait, bool debug)
{
	// only do a sleep if the first run - not for manual or retests
	if ((atoi(runNo) == 1) && wait)
	{
		TraceNoise("Sleeping for a bit", runNo, scriptID);

		// sleep for an offset of seconds
		sleep(scriptID % 60);
	}

	ConnectionPtr connection;
	std::string strQuery;
	bool download = true;

	try
	{
#ifdef SHARD_AWARE
		TraceLogic("Connecting to db", CConfig::getShardDatabase(shardNumber).c_str(), shardNumber);
		connection.reset(
			new Connection(
					CConfig::getShardServer(shardNumber),
					CConfig::getShardDatabase(shardNumber),
					CConfig::getShardUser(shardNumber),
					CConfig::getShardPass(shardNumber),
					CConfig::getDBRetryTime()));
#else
		TraceLogic("Connecting to db", CConfig::getDBDatabase(), 0);
		connection.reset(
			new Connection(
					CConfig::getDBServer(),
					CConfig::getDBDatabase(),
					CConfig::getDBUser(),
					CConfig::getDBPass(),
					CConfig::getDBRetryTime()));
#endif
	}
	catch (const std::exception &e)
	{
		LogError("Exception Caught:", e.what(), scriptID);
		return;
	}

	// if the ScriptID == 0 - get it from the batch table
	if (scriptID == 0)
	{
		strQuery = Format(SQL_WTTT_BATCH_SEL, batchID);
		TraceSQL("Issuing", "", 0);
		if (ResultPtr result = connection->Query(strQuery))
		{
			if (result->Next())
			{
				RowPtr row = result->GetCurrentRow();

				scriptID = row->GetFieldLong(1);

				TraceLogic("batchID", "", batchID);
				TraceLogic("scriptID", "", scriptID);
			}
		}
	}

	// script and archive names
	const std::string filename = Format("/home/sc/bin/monitor_scripts/%ld_%u", scriptID, shardNumber);
	const std::string gzfilename = filename + ".gz";

	// Get script details
	long customerNo = 0;
	SC_SCRIPT_LANGUAGE scriptlanguage = SC_SCRIPT_LANGUAGE_UNKNOWN;
	std::string scriptversion;
	strQuery = Format(SQL_WTTT_SCRIPTINFO_SEL, scriptID);
	TraceSQL("Issuing", "", 0);
	if (ResultPtr result = connection->Query(strQuery))
	{
		if (result->Next())
		{
			RowPtr row = result->GetCurrentRow();

			customerNo = row->GetFieldLong(1);
			scriptlanguage = static_cast<SC_SCRIPT_LANGUAGE>(row->GetFieldLong(2));

			// Field can be NULL, so check before dereference
			if (const char* str = row->GetField(3))
			{
				scriptversion = str;
			}

			TraceLogic("customerNo", "", customerNo);
			TraceLogic("scriptlanguage", to_string(scriptlanguage).c_str(), int(scriptlanguage));
			TraceLogic("scriptversion", scriptversion.c_str(), scriptversion.size());
		}
	}

	switch (scriptlanguage)
	{
	case SC_SCRIPT_LANGUAGE_UNKNOWN:
		//
		// No recognised script or script language returned
		//
//.........这里部分代码省略.........
开发者ID:tucci69,项目名称:tcp_ssl,代码行数:101,代码来源:wttt.cpp


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