本文整理汇总了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;
}
示例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
//
//.........这里部分代码省略.........