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


C++ NetworkAdapter::AddRef方法代码示例

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


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

示例1: TempFailureRetry

/*
void NetworkAdapterList::TempFailureRetry(Functor& aCallback)
{ // static
    static const TUint kDelaysMs[] = { 100, 200, 400, 800, 1600, 3200, 5000, 10000, 20000, 20000, 30000 }; // roughly 90s worth of retries
    for (TUint i=0; i<sizeof(kDelaysMs)/sizeof(kDelaysMs[0]); i++) {
        try {
            aCallback();
            return;
        }
        catch (NetworkError&) {
            LOG2(kNetwork, kError, "TempFailureRetry: error handling adapter change, try again in %ums\n", kDelaysMs[i]);
            Thread::Sleep(kDelaysMs[i]);
        }
    }
    THROW(NetworkError);
}
*/
std::vector<NetworkAdapter*>* NetworkAdapterList::CreateSubnetListLocked() const
{
    std::vector<NetworkAdapter*>* list = new std::vector<NetworkAdapter*>;
    for (TUint i=0; i<iNetworkAdapters->size(); i++) {
        NetworkAdapter* nif = (*iNetworkAdapters)[i];
        TIpAddress subnet = nif->Subnet();
        if (-1 == NetworkAdapterList::FindSubnet(subnet, *list)) {
            nif->AddRef("NetworkAdapterList");
            list->push_back(nif);
        }
    }
    return list;
}
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:30,代码来源:NetworkAdapterList.cpp

示例2:

std::vector<NetworkAdapter*>* NetworkAdapterList::CreateNetworkAdapterList() const
{
    iListLock.Wait();

    std::vector<NetworkAdapter*>* list = new std::vector<NetworkAdapter*>;
    for (TUint i=0; i<iNetworkAdapters->size(); i++) {
        NetworkAdapter* nif = (*iNetworkAdapters)[i];
        nif->AddRef("NetworkAdapterList");
        list->push_back(nif);
    }

    iListLock.Signal();
    return list;
}
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:14,代码来源:NetworkAdapterList.cpp

示例3: OhNetNetworkAdapterAddRef

void STDCALL OhNetNetworkAdapterAddRef(OhNetHandleNetworkAdapter aNif, const char* aCookie)
{
    NetworkAdapter* nif = reinterpret_cast<NetworkAdapter*>(aNif);
    ASSERT(nif != NULL);
    return nif->AddRef(aCookie);
}
开发者ID:sewood,项目名称:ohNet,代码行数:6,代码来源:OhNetC.cpp

示例4: HandleInterfaceListChanged

void NetworkAdapterList::HandleInterfaceListChanged()
{
    static const char* kRemovedAdapterCookie = "RemovedAdapter";
    iListLock.Wait();
    std::vector<NetworkAdapter*>* list = Os::NetworkListAdapters(iEnv, iEnv.InitParams()->LoopbackNetworkAdapter(), "NetworkAdapterList");
    TIpAddress oldAddress = (iCurrent==NULL ? 0 : iCurrent->Address());
    DestroySubnetList(iNetworkAdapters);
    iNetworkAdapters = list;

    // update the 'current' adapter and inform observers if it has changed
    UpdateCurrentAdapter();
    TIpAddress newAddress = (iCurrent==NULL? 0 : iCurrent->Address());

    // update the subnet list, noting if it has changed
    std::vector<NetworkAdapter*>* subnets = CreateSubnetListLocked();
    TBool subnetsChanged = false;
    if (subnets->size() != iSubnets->size()) {
        subnetsChanged = true;
    }
    else {
        for (TUint i=0; i<iSubnets->size(); i++) {
            if ((*iSubnets)[i]->Address() != (*subnets)[i]->Address()) {
                subnetsChanged = true;
                break;
            }
        }
    }

    // determine adds and/or removes from list
    std::vector<NetworkAdapter*> oldSubnetsObj(iSubnets->begin(), iSubnets->end());
    std::vector<NetworkAdapter*> newSubnetsObj(subnets->begin(), subnets->end());
    std::vector<NetworkAdapter*>* oldSubnets = &oldSubnetsObj;
    std::vector<NetworkAdapter*>* newSubnets = &newSubnetsObj;
    std::vector<NetworkAdapter*> added;
    std::vector<NetworkAdapter*> removed;
    std::vector<NetworkAdapter*> adapterChanged;

    std::sort(oldSubnets->begin(), oldSubnets->end(), CompareSubnets);
    std::sort(newSubnets->begin(), newSubnets->end(), CompareSubnets);

    if (oldSubnets->size() == 0 && newSubnets->size() > 0) {
        for (TUint i=0; i < newSubnets->size(); i++) {
            added.push_back((*newSubnets)[i]);
        }
    }
    else if (oldSubnets->size() > 0 && newSubnets->size() == 0) {
        for (TUint i=0; i < oldSubnets->size(); i++) {
            NetworkAdapter* removedAdapter = (*oldSubnets)[i];
            removed.push_back(removedAdapter);
            removedAdapter->AddRef(kRemovedAdapterCookie); // DestroySubnetList(iSubnets) may destroy the last ref to this before QueueAdapterRemoved later claims a new ref
        }
    }
    else {
        TUint j = 0;
        for (TUint i=0; i < newSubnets->size(); i++) {
            while (j < oldSubnets->size() && (*oldSubnets)[j]->Subnet() < (*newSubnets)[i]->Subnet()) {
                NetworkAdapter* removedAdapter = (*oldSubnets)[j];
                removed.push_back(removedAdapter);
                removedAdapter->AddRef(kRemovedAdapterCookie);
                j++;
            }
            if (j < oldSubnets->size() && (*oldSubnets)[j]->Subnet() == (*newSubnets)[i]->Subnet()) {
                if ((*oldSubnets)[j]->Address() != (*newSubnets)[i]->Address()) {
                    adapterChanged.push_back((*newSubnets)[i]);
                }
                j++;
            }
        }
        if (j < oldSubnets->size()) {
            while (j < oldSubnets->size()) {
                NetworkAdapter* removedAdapter = (*oldSubnets)[j];
                removed.push_back(removedAdapter);
                removedAdapter->AddRef(kRemovedAdapterCookie);
                j++;
            }
        }
        j = 0;
        for (TUint i=0; i < oldSubnets->size(); i++) {
            while (j < newSubnets->size() && (*newSubnets)[j]->Subnet() < (*oldSubnets)[i]->Subnet()) {
                added.push_back((*newSubnets)[j]);
                j++;
            }
            if (j < newSubnets->size() && (*newSubnets)[j]->Subnet() == (*oldSubnets)[i]->Subnet()) {
                j++;
            }
        }
        if (j < newSubnets->size()) {
            while (j < newSubnets->size()) {
                added.push_back((*newSubnets)[j]);
                j++;
            }
        }
    }

    DestroySubnetList(iSubnets);
    iSubnets = subnets;
    iListLock.Signal();

    if (subnetsChanged) {
        iNotifierThread->QueueSubnetsChanged();
//.........这里部分代码省略.........
开发者ID:MatthewMiddleweek,项目名称:ohNet,代码行数:101,代码来源:NetworkAdapterList.cpp


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