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


C++ Duration::toMilliseconds方法代码示例

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


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

示例1: checkNotFoundData

//this function tells us if there are any ids that have waited long enough for it to be safe to query for the again.
void CraqObjectSegmentation::checkNotFoundData()
{
    if (mStopping)
        return;

    //look at the first element of the queue.  if the time hasn't been sufficiently long, return.  if the time has been sufficiently long, then go ahead and directly request asyncCraq to perform another lookup.

    if (mNfData.size() == 0)
        return;

    std::cout<<"\n\nGOT NOT FOUND\n\n";

    Duration tmpDur = Time::local() - Time::epoch();


    bool queueDataOldEnough = true;
    NotFoundData* nfd;

    while (queueDataOldEnough)
    {
        nfd = mNfData.front();
        queueDataOldEnough = false;

        if ((tmpDur.toMilliseconds() - nfd->dur.toMilliseconds()) > CRAQ_NOT_FOUND_SIT_OUT) //we wait 500 ms.
        {
            queueDataOldEnough = true;

            //perform a direct craq get call
            std::string indexer = "";
            indexer.append(1,myUniquePrefixKey);
            indexer.append(nfd->obj_id.rawHexData());

            CraqDataSetGet cdSetGet (indexer,CraqEntry(NullServerID,0),false,CraqDataSetGet::GET); //bftm modified
            craqDhtGet1.get(cdSetGet, nfd->traceToken); //calling the craqDht to do a get.

            mNfData.pop(); //remove the item from the queue.

            delete nfd; //memory managment
        }
        queueDataOldEnough = queueDataOldEnough && (mNfData.size() > 0);  //don't keep going if you're out of objects.
    }
}
开发者ID:pathorn,项目名称:sirikata,代码行数:43,代码来源:CraqObjectSegmentation.cpp

示例2: migrateObject

/*
  If we get a message to move an object that our server holds, then we add the object's id to mInTransit.
  Whatever calls this must verify that the object is on this server.
  I can do the check in the function by querrying bambooDht as well
*/
void CraqObjectSegmentation::migrateObject(const UUID& obj_id, const OSegEntry& new_server_id)
{
    if (mStopping)
        return;

    //log the message.
    CONTEXT_SPACETRACE(objectBeginMigrate,
                       obj_id,mContext->id(),
                       new_server_id.server());

    InTransitMap::const_iterator transIter = mInTransitOrLookup.find(obj_id);

    TransLookup tmpTransLookup;
    tmpTransLookup.sID = CraqEntry(new_server_id);

    Duration tmpDurer = Time::local() - Time::epoch();

    tmpTransLookup.timeAdmitted = (int)tmpDurer.toMilliseconds();

    mInTransitOrLookup[obj_id] = tmpTransLookup;

    //erases the local copy of obj_id
    UUID tmp_id = obj_id; //note: can probably delete this line

    //erase the local copy of the object.
    size_t num_erased = mObjects.erase(obj_id);
#ifdef CRAQ_DEBUG
    if (num_erased == 0)
    {
        std::cout<<"\n\nThe object clearly wasn't registered on this server.  This is obj id:  " <<  obj_id.toString() <<  ".  This is time:   " <<mContext->simTime().raw() << " Oh no.   ";

        if (clearToMigrate(obj_id))
            std::cout<<"  Likely a problem with clear to migrate\n\n";
        else
            std::cout<<"\n\n clear to migrate is fine migration is being called from somewhere besides server.cpp\n\n";
    }
#endif
}
开发者ID:pathorn,项目名称:sirikata,代码行数:43,代码来源:CraqObjectSegmentation.cpp


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