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


C++ Msg::setUnit方法代码示例

本文整理汇总了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);
}
开发者ID:Abhishekpatil,项目名称:SonATA,代码行数:29,代码来源:WorkerTask.cpp

示例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();
}
开发者ID:AgapegamerX,项目名称:SonATA,代码行数:38,代码来源:DetectionTask.cpp

示例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:
//.........这里部分代码省略.........
开发者ID:sigblips,项目名称:GiD-SonATA-old,代码行数:101,代码来源:SseInputTask.cpp


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