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


C++ Timeval::elapsed方法代码示例

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


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

示例1: commit

bool ReportingTable::commit()
{
	ReportBatch oustanding;
	ReportBatch::iterator mp;
	unsigned oustandingCount = 0;

	// copy out to free up access to mBatch as quickly as possible
	mLock.lock();
	mp = mBatch.begin();
	while (mp != mBatch.end()) {
		if (mp->second > 0) {
			oustanding[mp->first] = mp->second;
			mBatch[mp->first] = 0;
			oustandingCount++;
		}
		mp++;
	}
	mLock.unlock();

	// now actually write them into the db if needed
	if (oustandingCount > 0) {
		Timeval timer;
		char cmd[200];

		// TODO : could wrap this in a BEGIN; COMMIT; pair to transactionize these X UPDATEs
		mp = oustanding.begin();
		while (mp != oustanding.end()) {
			sprintf(cmd,"UPDATE REPORTING SET VALUE=VALUE+%u, UPDATETIME=%ld WHERE NAME=\"%s\"", mp->second, time(NULL), mp->first.c_str());
			if (!sqlite3_command(mDB,cmd)) {
				LOG(CRIT) << "could not increment reporting parameter " << mp->first << ", error message: " << sqlite3_errmsg(mDB);
			}
			mp++;
		}

		LOG(INFO) << "wrote " << oustandingCount << " entries in " << timer.elapsed() << "ms";
	}

	return true;
}
开发者ID:jaemannyeh,项目名称:nopebts,代码行数:39,代码来源:Reporting.cpp

示例2: MOSMSController


//.........这里部分代码省略.........
	// LAPDm operation, from GSM 04.11, Annex F:
	// """
	// Case A: Mobile originating short message transfer, no parallel call:
	// The mobile station side will initiate SAPI 3 establishment by a SABM command
	// on the SDCCH after the cipher mode has been set. If no hand over occurs, the
	// SAPI 3 link will stay up until the last CP-ACK is received by the MSC, and
	// the clearing procedure is invoked.
	// """

	// FIXME: check provisioning

	// Let the phone know we're going ahead with the transaction.
	LOG(INFO) << "sending CMServiceAccept";
	LCH->send(L3CMServiceAccept());
	// Wait for SAP3 to connect.
	// The first read on SAP3 is the ESTABLISH primitive.
	delete getFrameSMS(LCH,ESTABLISH);

	// Step 1
	// Now get the first message.
	// Should be CP-DATA, containing RP-DATA.
	L3Frame *CM = getFrameSMS(LCH);
	LOG(DEBUG) << "data from MS " << *CM;
	if (CM->MTI()!=CPMessage::DATA) {
		LOG(NOTICE) << "unexpected SMS CP message with TI=" << CM->MTI();
		throw UnexpectedMessage();
	}
	unsigned TI = CM->TIValue();

	// Step 2
	// Respond with CP-ACK.
	// This just means that we got the message.
	LOG(INFO) << "sending CPAck";
	LCH->send(CPAck(1,TI),3);

	// Parse the message in CM and process RP part.
	// This is where we actually parse the message and send it out.
	// FIXME -- We need to set the message ref correctly,
	// even if the parsing fails.
	// The compiler gives a warning here.  Let it.  It will remind someone to fix it.
	unsigned ref;
	bool success = false;
	try {
		CPData data;
		data.parse(*CM);
		delete CM;
		LOG(INFO) << "CPData " << data;
		// Transfer out the RPDU -> TPDU -> delivery.
		ref = data.RPDU().reference();
		// This handler invokes higher-layer parsers, too.
		success = handleRPDU(mobileIdentity,data.RPDU());
	}
	catch (SMSReadError) {
		LOG(WARN) << "SMS parsing failed (above L3)";
		// Cause 95, "semantically incorrect message".
		LCH->send(CPData(1,TI,RPError(95,ref)),3);
		throw UnexpectedMessage();
	}
	catch (L3ReadError) {
		LOG(WARN) << "SMS parsing failed (in L3)";
		throw UnsupportedMessage();
	}

	// Step 3
	// Send CP-DATA containing RP-ACK and message reference.
	if (success) {
		LOG(INFO) << "sending RPAck in CPData";
		LCH->send(CPData(1,TI,RPAck(ref)),3);
	} else {
		LOG(INFO) << "sending RPError in CPData";
		// Cause 127 is "internetworking error, unspecified".
		// See GSM 04.11 Table 8.4.
		LCH->send(CPData(1,TI,RPError(127,ref)),3);
	}

	// Step 4
	// Get CP-ACK from the MS.
	CM = getFrameSMS(LCH);
	if (CM->MTI()!=CPMessage::ACK) {
		LOG(NOTICE) << "unexpected SMS CP message with TI=" << CM->MTI();
		throw UnexpectedMessage();
	}
	LOG(DEBUG) << "ack from MS: " << *CM;
	CPAck ack;
	ack.parse(*CM);
	LOG(INFO) << "CPAck " << ack;

	// RRLP Here if enabled
	if (gConfig.defines("GSM.RRLP") && gConfig.getNum("GSM.RRLP") == 1 &&
		gConfig.defines("RRLP.LocationUpdate") && gConfig.getNum("RRLP.LocationUpdate") == 1 /* RRLP? */)
	{
		Timeval start;
		RRLP::collectMSInfo(mobileIdentity, LCH, true /* DO RRLP */);
		LOG(INFO) << "submitSMS with RRLP took " << start.elapsed() << " for IMSI " << mobileIdentity;
	}

	// Done.
	LOG(INFO) << "closing";
	LCH->send(L3ChannelRelease());
}
开发者ID:0x7678,项目名称:openbts-uhd,代码行数:101,代码来源:SMSControl.cpp


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