本文整理汇总了C++中CSocket::dbt5Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C++ CSocket::dbt5Disconnect方法的具体用法?C++ CSocket::dbt5Disconnect怎么用?C++ CSocket::dbt5Disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocket
的用法示例。
在下文中一共展示了CSocket::dbt5Disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
// worker thread
void *MarketWorkerThread(void* data)
{
PMarketThreadParam pThrParam = reinterpret_cast<PMarketThreadParam>(data);
CSocket sockDrv;
sockDrv.setSocketFd(pThrParam->iSockfd); // client socket
PTradeRequest pMessage = new TTradeRequest;
memset(pMessage, 0, sizeof(TTradeRequest)); // zero the structure
do {
try {
sockDrv.dbt5Receive(reinterpret_cast<void*>(pMessage),
sizeof(TTradeRequest));
// submit trade request
pThrParam->pMarketExchange->m_pCMEE->SubmitTradeRequest(pMessage);
} catch(CSocketErr *pErr) {
sockDrv.dbt5Disconnect(); // close connection
ostringstream osErr;
osErr << time(NULL) <<
" Trade Request not submitted to Market Exchange" << endl <<
"Error: "<<pErr->ErrorText() << endl;
pThrParam->pMarketExchange->logErrorMessage(osErr.str());
delete pErr;
// The socket is closed, break and let this thread die.
break;
}
} while (true);
delete pMessage;
delete pThrParam;
return NULL;
}
示例2: marketFeedDB
void *workerThread(void *data)
{
signal(SIGTERM, signal_kill_handler);
try {
PThreadParameter pThrParam = reinterpret_cast<PThreadParameter>(data);
CSocket sockDrv;
sockDrv.setSocketFd(pThrParam->iSockfd); // client socket
#ifndef NO_DEBUG_INFO
ostringstream msg2;
msg2<<"workerThread "<<pThrParam->t_id<<", start, iSockfd = "<<pThrParam->iSockfd<<endl;
pThrParam->pBrokerageHouse->logErrorMessage(msg2.str());
#endif
PMsgDriverBrokerage pMessage = new TMsgDriverBrokerage;
memset(pMessage, 0, sizeof(TMsgDriverBrokerage)); // zero the structure
TMsgBrokerageDriver Reply; // return message
INT32 iRet = 0; // transaction return code
CDBConnection *pDBConnection = NULL;
#ifdef DB_PGSQL
// new database connection
pDBConnection = new CDBConnection(
pThrParam->pBrokerageHouse->m_szHost,
pThrParam->pBrokerageHouse->m_szDBName,
pThrParam->pBrokerageHouse->m_szDBPort);
#else
pDBConnection = new CDBConnection(
pThrParam->pBrokerageHouse,
pThrParam->pBrokerageHouse->mysql_dbname,
pThrParam->pBrokerageHouse->mysql_host,
pThrParam->pBrokerageHouse->mysql_user,
pThrParam->pBrokerageHouse->mysql_pass,
pThrParam->pBrokerageHouse->mysql_port_t,
pThrParam->pBrokerageHouse->mysql_socket_t);
pDBClist[pThrParam->t_id] = pDBConnection;
#ifdef CAL_RESP_TIME
pDBConnection->init_profile_node(pThrParam->t_id, pThrParam->outputDir);
#endif
#endif
pDBConnection->setBrokerageHouse(pThrParam->pBrokerageHouse);
CSendToMarket sendToMarket = CSendToMarket(
&(pThrParam->pBrokerageHouse->m_fLog));
#ifdef NO_MEE_FOR_TRADERESULT
sendToMarket.m_pCMEE = pThrParam->pBrokerageHouse->m_pCMEE[pThrParam->t_id%pThrParam->pBrokerageHouse->iUsers];
#endif
CMarketFeedDB marketFeedDB(pDBConnection);
CMarketFeed marketFeed = CMarketFeed(&marketFeedDB, &sendToMarket);
CTradeOrderDB tradeOrderDB(pDBConnection);
CTradeOrder tradeOrder = CTradeOrder(&tradeOrderDB, &sendToMarket);
// Initialize all classes that will be used to execute transactions.
CBrokerVolumeDB brokerVolumeDB(pDBConnection);
CBrokerVolume brokerVolume = CBrokerVolume(&brokerVolumeDB);
CCustomerPositionDB customerPositionDB(pDBConnection);
CCustomerPosition customerPosition = CCustomerPosition(&customerPositionDB);
CMarketWatchDB marketWatchDB(pDBConnection);
CMarketWatch marketWatch = CMarketWatch(&marketWatchDB);
CSecurityDetailDB securityDetailDB = CSecurityDetailDB(pDBConnection);
CSecurityDetail securityDetail = CSecurityDetail(&securityDetailDB);
CTradeLookupDB tradeLookupDB(pDBConnection);
CTradeLookup tradeLookup = CTradeLookup(&tradeLookupDB);
CTradeStatusDB tradeStatusDB(pDBConnection);
CTradeStatus tradeStatus = CTradeStatus(&tradeStatusDB);
CTradeUpdateDB tradeUpdateDB(pDBConnection);
CTradeUpdate tradeUpdate = CTradeUpdate(&tradeUpdateDB);
CDataMaintenanceDB dataMaintenanceDB(pDBConnection);
CDataMaintenance dataMaintenance = CDataMaintenance(&dataMaintenanceDB);
CTradeCleanupDB tradeCleanupDB(pDBConnection);
CTradeCleanup tradeCleanup = CTradeCleanup(&tradeCleanupDB);
CTradeResultDB tradeResultDB(pDBConnection);
CTradeResult tradeResult = CTradeResult(&tradeResultDB);
int txn_cnt = 0;
int abort_cnt = 0;
double txn_time = 0;
bool commit = true;
double receiving_time = 0;
// gettimeofday(&(pDBConnection->t1), NULL);
do {
try {
//gettimeofday(&tt1, NULL);
sockDrv.dbt5Receive(reinterpret_cast<void *>(pMessage),
sizeof(TMsgDriverBrokerage));
//gettimeofday(&tt2, NULL);
//if(txn_cnt > 0 && difftimeval(tt2, tt1)>1)pDBConnection->outfile<<"END"<<endl;
//pDBConnection->outfile.flush();
} catch(CSocketErr *pErr) {
sockDrv.dbt5Disconnect();
ostringstream osErr;
osErr << "Error on Receive: " << pErr->ErrorText() <<
" at BrokerageHouse::workerThread" << endl;
pThrParam->pBrokerageHouse->logErrorMessage(osErr.str());
delete pErr;
// The socket has been closed, break and let this thread die.
break;
//.........这里部分代码省略.........
示例3: tpccDB
void *workerThread(void *data)
{
signal(SIGTERM, signal_kill_handler);
try {
PThreadParameter pThrParam = reinterpret_cast<PThreadParameter>(data);
CSocket sockDrv;
sockDrv.setSocketFd(pThrParam->iSockfd); // client socket
PMsgDriverTPCC pMessage = new TMsgDriverTPCC;
memset(pMessage, 0, sizeof(TMsgDriverTPCC)); // zero the structure
TMsgTPCCDriver Reply; // return message
INT32 iRet = 0; // transaction return code
CDBConnection *pDBConnection = NULL;
pDBConnection = new CDBConnection(
pThrParam->pTPCC,
pThrParam->pTPCC->mysql_dbname,
pThrParam->pTPCC->mysql_host,
pThrParam->pTPCC->mysql_user,
pThrParam->pTPCC->mysql_pass,
pThrParam->pTPCC->mysql_port_t,
pThrParam->pTPCC->mysql_socket_t);
#ifdef CAL_RESP_TIME
timeval t1, t2;
double exec_time;
pDBClist[pThrParam->t_id] = pDBConnection;
pDBConnection->init_profile_node(pThrParam->t_id, pThrParam->outputDir);
#endif
CTPCCDB tpccDB(pDBConnection);
int txn_cnt = 0;
int abort_cnt = 0;
double txn_time = 0;
bool commit = true;
double receiving_time = 0;
do {
try {
sockDrv.dbt5Receive(reinterpret_cast<void *>(pMessage),
sizeof(TMsgDriverTPCC));
} catch(CSocketErr *pErr) {
sockDrv.dbt5Disconnect();
delete pErr;
// The socket has been closed, break and let this thread die.
break;
}
timeval t1, t2;
double exec_time;
gettimeofday(&t1, NULL);
commit = true;
iRet = CBaseTxnErr::SUCCESS;
try {
// Parse Txn type
switch (pMessage->TxnType) {
case NEWORDER:
iRet = pThrParam->pTPCC->RunNewOrder(&pMessage->TxnInput.neworderTxnInput, tpccDB);
break;
case PAYMENT:
iRet = pThrParam->pTPCC->RunPayment(&pMessage->TxnInput.paymentTxnInput, tpccDB);
break;
case DELIVERY:
iRet = pThrParam->pTPCC->RunDelivery(&pMessage->TxnInput.deliveryTxnInput, tpccDB);
break;
case STOCKLEVEL:
iRet = pThrParam->pTPCC->RunStocklevel(&pMessage->TxnInput.stocklevelTxnInput, tpccDB);
break;
case ORDERSTATUS:
iRet = pThrParam->pTPCC->RunOrderstatus(&pMessage->TxnInput.orderstatusTxnInput, tpccDB);
break;
default:
pDBConnection->outfile<<"Wrong txn type!"<<endl;
iRet = ERR_TYPE_WRONGTXN;
}
txn_cnt++;
pDBConnection->txn_cnt = txn_cnt;
}catch (const char *str) {
pDBConnection->rollback();
//#ifdef CAL_RESP_TIME
// gettimeofday(&t2, NULL);
// exec_time = difftimeval(t2, t1);
// txn_time += exec_time;
//#ifdef PROFILE_EACH_QUERY
// pDBConnection->print_profile_query();
//#endif
// pDBConnection->outfile.flush();
//#endif
//cout<<"error: "<<str<<endl;
iRet = CBaseTxnErr::EXPECTED_ROLLBACK;
commit = false;
abort_cnt++;
pDBConnection->abort_cnt = abort_cnt;
//.........这里部分代码省略.........