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


C++ MessagePtr::size方法代码示例

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


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

示例1: NetworkInterfaceStopTransmittingEvent

void P2PNetworkInterface::send() {
	MessagePtr msg;
	stringstream info;
	uint64_t transmissionDuration;
	double rate;

	if (!connectedInterface) {
		info << "*** WARNING *** [block " << hostBlock->blockId << ",interface " << globalId <<"] : trying to send a Message but no interface connected";
		BaseSimulator::getScheduler()->trace(info.str());
		return;
	}

	if (outgoingQueue.size()==0) {
		info << "*** ERROR *** [block " << hostBlock->blockId << ",interface " << globalId <<"] : The outgoing buffer of this interface should not be empty !";
		BaseSimulator::getScheduler()->trace(info.str());
		exit(EXIT_FAILURE);
	}

	msg = outgoingQueue.front();
	outgoingQueue.pop_front();

	rate = dataRate - dataRateVariability + (generator()/(double)RAND_MAX) * 2 * dataRateVariability;
	transmissionDuration = (msg->size()*8000000ULL)/rate;
	messageBeingTransmitted = msg;
	messageBeingTransmitted->sourceInterface = this;
	messageBeingTransmitted->destinationInterface = connectedInterface;

	availabilityDate = BaseSimulator::getScheduler()->now()+transmissionDuration;
	//info << "*** sending (interface " << localId << " of block " << hostBlock->blockId << ")";
	//getScheduler()->trace(info.str());

	BaseSimulator::getScheduler()->schedule(new NetworkInterfaceStopTransmittingEvent(BaseSimulator::getScheduler()->now()+transmissionDuration, this));
}
开发者ID:adikolo,项目名称:visiblesim,代码行数:33,代码来源:network.cpp

示例2: getScheduler

void Flavio01BlockCode::processLocalEvent(EventPtr pev) {
	MessagePtr message;
	stringstream info;

	//info << "FlavioBlockCode processing a local event : " << pev->getEventName();
	//Scheduler::trace(info.str());

	switch (pev->eventType) {
	case EVENT_NI_RECEIVE:
		{
			unsigned int sourceId;
			message = (boost::static_pointer_cast<NetworkInterfaceReceiveEvent>(pev))->message;
			sourceId = message->sourceInterface->hostBlock->blockId;
			info.str("");
			info << "Block " << hostBlock->blockId << " received a message from " << sourceId;
			info << "   size : " << message->size();
			getScheduler()->trace(info.str());
			VMMessage response;
			response.messageType = VM_MESSAGE_TYPE_RECEIVE_MESSAGE;
			response.param1 = hostBlock->blockId;
			response.param2 = getScheduler()->now();
			response.param3 = message->size();
//			((MultiCoresBlock*)hostBlock)->setUndefinedState(true);
			getScheduler()->addUndefinedBlock(hostBlock->blockId);
			VM_TRACE_MESSAGE(response);
			getScheduler()->sendMessageToVM(response);
			waitingForVM = true;
		}
		break;
	case EVENT_VM_END_COMPUTATION:
		{
			computing = false;
			//boost::shared_ptr<EndComputationEvent>endComputationEvent = (boost::static_pointer_cast<EndComputationEvent>(pev));
			info.str("");
			info << "FlavioBlockCode " << hostBlock->blockId << " finished its computation";
			getScheduler()->trace(info.str());
			VMMessage response;
			response.messageType = VM_MESSAGE_TYPE_COMPUTATION_UNLOCK;
			response.param1 = hostBlock->blockId;
			response.param2 = getScheduler()->now();
//			((MultiCoresBlock*)hostBlock)->setUndefinedState(true);
			getScheduler()->addUndefinedBlock(hostBlock->blockId);
			VM_TRACE_MESSAGE(response);
			getScheduler()->sendMessageToVM(response);
			waitingForVM = true;
		}
		break;
	case EVENT_VM_START_COMPUTATION:
		uint64_t duration;
		if (computing) {
			info.str("");
			info << "*** ERROR *** block " << hostBlock->blockId << " got a COMPUTATION_LOCK from VM but it was already computing !";
			getScheduler()->trace(info.str());
		}
		if (!waitingForVM) {
			info.str("");
			info << "*** ERROR *** block " << hostBlock->blockId << " got a COMPUTATION_LOCK from VM but was not waiting for one";
			getScheduler()->trace(info.str());
		}
		computing = true;
		waitingForVM = false;
		duration = (boost::static_pointer_cast<VMStartComputationEvent>(pev))->duration;
		availabilityDate = getScheduler()->now()+duration;
		info.str("");
		info << "FlavioBlockCode " << hostBlock->blockId << " starting computation (will last for " << duration << ")" ;
		getScheduler()->trace(info.str());
		getScheduler()->schedule(new VMEndComputationEvent(getScheduler()->now()+duration, (MultiCoresBlock*)hostBlock));
		break;
	case EVENT_VM_START_TRANSMISSION:
		{
			unsigned int destId = (boost::static_pointer_cast<VMStartTransmissionEvent>(pev))->destBlockId;
			unsigned int messageSize = (boost::static_pointer_cast<VMStartTransmissionEvent>(pev))->messageSize;
			info.str("");
			info << "FlavioBlockCode " << hostBlock->blockId << " was asked to start transmitting to " << destId;
			getScheduler()->trace(info.str());

			P2PNetworkInterface *interface;
			interface = hostBlock->getP2PNetworkInterfaceByDestBlockId(destId);
			getScheduler()->schedule(new NetworkInterfaceEnqueueOutgoingEvent(getScheduler()->now(),new VMDataMessage(messageSize), interface));
		}
		break;
	default:
		break;
	}
}
开发者ID:adikolo,项目名称:visiblesim,代码行数:85,代码来源:flavio01BlockCode.cpp


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