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


C++ Packet::GetPktType方法代码示例

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


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

示例1: lock

int Ts2::Network::RouteManager::CancelDataPackets(u32 srcVtId)
{
    int err = 0;

    {
        MutexAutoLock lock(&mutex);
        state.clients++;
        if (state.stop == STOP_STATE_STOPPING) {
            LOG_WARN("RouteManager[%p]: Method called after Stop", this);
        }

        // Removing an element from the middle of a queue maybe expensive.
        // Thus, instead of removing it, we will simply replace the pointer to a Packet obj with a NULL pointer.
        // Dequeue code (in packetThreadMain()) will check the pointer value and ignore if NULL.
        std::deque<std::pair<Packet*, VPLTime_t> >::iterator it;
        for (it = packetQueue.begin(); it != packetQueue.end(); it++) {
            Packet *packet = it->first;
            if (packet && (packet->GetPktType() == TS_PKT_DATA) && (packet->GetSrcVtId() == srcVtId)) {
                delete packet;     // destroy Packet obj
                it->first = NULL;  // replace pointer with NULL pointer
            }
        }
    }

    {
        // If the worker thread is trying to send, wait until it is done.
        // This is necessary, since it may be currently processing a packet that
        // would have been cancelled by the loop above.
        MutexAutoLock lock(&mutex_packetThreadSending);
        while (packetThreadSending) {
            err = VPLCond_TimedWait(&cond_packetThreadSending, &mutex_packetThreadSending, VPL_TIMEOUT_NONE);
            if (err) {
                LOG_ERROR("RouteManager[%p]: CondVar failed: err %d", this, err);
                err = 0;  // Reset error and exit.
                break;
            }
        }
    }

    {
        MutexAutoLock lock(&mutex);
        state.clients--;
        if (state.clients == 0) {
            VPLCond_Broadcast(&cond_state_noClients);
        }
    }

    return err;
}
开发者ID:iversonjimmy,项目名称:acer_cloud_wifi_copy,代码行数:49,代码来源:Ts2_RouteManager.cpp


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