本文整理汇总了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));
}
示例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;
}
}