本文整理汇总了C++中Msg::setUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg::setUnit方法的具体用法?C++ Msg::setUnit怎么用?C++ Msg::setUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Msg
的用法示例。
在下文中一共展示了Msg::setUnit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* Notify the collection task that data collection is complete.
*/
void
WorkerTask::completeDataCollection()
{
// done with data collection; report completion to collection task
// and any packet reception problems to SSE.
ChannelStatistics stats;
channel->getStats(stats);
Debug(DEBUG_ALWAYS, (int32_t) stats.netStats.total,
"total packets");
Debug(DEBUG_ALWAYS, (int32_t) stats.netStats.missed,
"missed packets");
Debug(DEBUG_ALWAYS, (int32_t) stats.netStats.late,
"late packets");
if ((stats.netStats.missed + stats.netStats.late) > 0 && activity) {
LogWarning(ERR_LMP, activity->getActivityId(),
"channel %d, total packets = %d, missed = %d, late = %d",
channel->getChannelNum(), stats.netStats.total,
stats.netStats.missed, stats.netStats.late);
}
Msg *cMsg = msgList->alloc(DATA_COLLECTION_COMPLETE, activityId,
reinterpret_cast<void *> (channel->getChannelNum()), 0, 0,
IMMEDIATE);
cMsg->setUnit((sonata_lib::Unit) unit);
collectionQ->send(cMsg);
stopActivity(activity);
}
示例2:
//
// stopActivity: stop an activity
//
// Synopsis:
// void stopActivity(msg, stopAll);
// Msg *msg; ptr to message
// bool stopAll; stop all activities
// Returns:
// Nothing.
// Description:
// Stops either the specified activity or any activity
// which is currently active.
// Notes:
// Sends messages to the collection tasks.
// Note that this task never kills a collecting
// activity directly; instead, it sends
// messages to the individual collection subtasks
// instructing them to kill the task and report back
// that it has been completed.
//
void
DetectionTask::stopActivity(Msg *msg, bool stopAll)
{
// if no activity is detecting, ignore the message
if (!activity ||
(!stopAll && activity->getActivityId() != msg->getActivityId())) {
Msg *cMsg = msgList->alloc((DxMessageCode) ActivityStopped,
msg->getActivityId());
cMsg->setUnit((sonata_lib::Unit) UnitDetect);
controlQ->send(cMsg);
return;
}
// stop both of the detectors (only one can be running,
// but we don't know which one)
stopDetection();
}
示例3: extractArgs
//
// routine: receive and send on incoming messages
//
// Notes:
// No analysis of the message is performed - that is left
// to the command processor task. Instead, the local copy
// of the header
// is demarshalled to determined whether or not there
// is associated data; if there is, space is allocated to
// contain it.
void *
SseInputTask::routine()
{
extractArgs();
Timer timer;
if (cmdArgs->noSSE()) {
processIpFromFile();
while (1)
timer.sleep(3000);
};
// run forever, waiting for messages from the SSE
bool stopIssued = false;
bool done = false;
uint32_t lastCode = MESSAGE_CODE_UNINIT;
int32_t lastLen = 0;
uint32_t lastTime = 0;
while (!done) {
// if there's no connection, request that it be
// established, then wait for that to happen
if (!sse->isConnected()) {
requestConnection();
while (!sse->isConnected())
timer.sleep(3000);
}
stopIssued = false;
// got a connection - wait for data to come in
SseInterfaceHeader hdr;
Error err = sse->recv((void *) &hdr, sizeof(hdr));
if (err) {
switch (err) {
case EAGAIN:
case EINTR:
case ENOTCONN:
case ECONNRESET:
stopAllActivities(stopIssued);
continue;
default:
Fatal(err);
break;
}
}
// demarshall the header
hdr.demarshall();
if (cmdArgs->logSseMessages()) {
LogWarning(ERR_NE, hdr.activityId,
"bad msg from Sse, code = %d, len = %d", hdr.code,
hdr.dataLength);
}
// allocate a message to hold the incoming message
Msg *msg = msgList->alloc();
msg->setHeader(hdr);
msg->setUnit((sonata_lib::Unit) UnitSse);
// if there's data associated with the message,
// allocate space and retrieve it, demarshall it
// based on the message type,
// then send it on to the command processor
void *data = 0;
int32_t len = hdr.dataLength;
timeval tv;
gettimeofday(&tv, NULL);
if (len > 10000) {
LogWarning(ERR_NE, hdr.activityId,
"msg code = %d, len = %d, t = %u, last msg = %d, last len = %d, last t = %u",
hdr.code, len, tv.tv_sec, lastCode, lastLen, lastTime);
Timer t;
t.sleep(100);
}
else {
lastCode = hdr.code;
lastLen = len;
lastTime = tv.tv_sec;
}
if (len) {
MemBlk *blk = partitionSet->alloc(len);
Assert(blk);
if (!blk)
Fatal(ERR_MAF);
data = blk->getData();
err = sse->recv(data, len);
if (err) {
switch (err) {
case EAGAIN:
case EINTR:
case ENOTCONN:
//.........这里部分代码省略.........