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


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

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


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

示例1: post

void IOService::post(const Duration& waitFor, const IOCallback& handler, const char* tag, const char* tagStat) {
#if BOOST_VERSION==103900
    static bool warnOnce=true;
    if (warnOnce) {
        warnOnce=false;
        SILOG(core,error,"Using buggy version of boost (1.39.0), leaking deadline_timer to avoid crash");
    }
#endif
    deadline_timer_ptr timer(new deadline_timer(*mImpl, posix_microseconds(waitFor.toMicroseconds())));

#ifdef SIRIKATA_TRACK_EVENT_QUEUES
    mTimersEnqueued++;
    {
        LockGuard lock(mMutex);
        if (mTagCounts.find(tag) == mTagCounts.end())
            mTagCounts[tag] = 0;
        mTagCounts[tag]++;
    }
    IOCallbackWithError orig_cb = std::tr1::bind(&handle_deadline_timer, _1, timer, handler);
    timer->async_wait(
        std::tr1::bind(&IOService::decrementTimerCount, this,
            _1, Timer::now(), waitFor, orig_cb, tag,tagStat
        )
    );
#else
    timer->async_wait(std::tr1::bind(&handle_deadline_timer, _1, timer, handler));
#endif
}
开发者ID:SinSiXX,项目名称:sirikata,代码行数:28,代码来源:IOService.cpp

示例2: wait

void TimerHandle::wait(
        const std::tr1::shared_ptr<TimerHandle> &thisPtr,
        const Duration &num_seconds) {
    mTimer->expires_from_now(boost::posix_time::microseconds(num_seconds.toMicroseconds()));
    std::tr1::weak_ptr<TimerHandle> weakThisPtr(thisPtr);
    mTimer->async_wait(
        boost::bind(
            &TimerHandle::TimedOut::timedOut,
            boost::asio::placeholders::error,
            weakThisPtr));
}
开发者ID:MikeSofaer,项目名称:sirikata,代码行数:11,代码来源:IOServiceFactory.cpp

示例3: start

void TimerSpeedBenchmark::start() {
    mForceStop = false;

    // Check throughput of timer calls
    Time start_time = Timer::now();

    Time dummy_t = Time::null();
    for(uint32 ii = 0; ii < ITERATIONS && !mForceStop; ii++)
        dummy_t = Timer::now();

    if (mForceStop)
        return;

    Time end_time = Timer::now();
    Duration dur = end_time - start_time;

    SILOG(benchmark,info,
          ITERATIONS << " timer invokations, " << dur << ": "
          << (dur.toMicroseconds()*1000/float(ITERATIONS)) << "ns/call, "
          << float(ITERATIONS)/dur.toSeconds() << " calls/s");

    notifyFinished();
}
开发者ID:AsherBond,项目名称:sirikata,代码行数:23,代码来源:TimerSpeedBenchmark.cpp

示例4: TimerHandler

    TimerHandler(Network::IOService *io, SentMessage *messageInfo, const Duration& num_seconds)
        : mTimer(*static_cast<boost::asio::io_service*>(io), boost::posix_time::microseconds(num_seconds.toMicroseconds())) {

        mSentMessage = messageInfo;
        mTimer.async_wait(
            boost::bind(&TimerHandler::timedOut, this, boost::asio::placeholders::error));
    }
开发者ID:danx0r,项目名称:sirikata,代码行数:7,代码来源:SentMessage.cpp

示例5: post

void IOService::post(const Duration& waitFor, const IOCallback& handler) {
    deadline_timer_ptr timer(new deadline_timer(*mImpl, posix_microseconds(waitFor.toMicroseconds())));
    timer->async_wait(std::tr1::bind(&handle_deadline_timer, _1, timer, handler));
}
开发者ID:danielrh,项目名称:sirikata,代码行数:4,代码来源:IOService.cpp

示例6: dispatchServiceMessage

void IOServiceFactory::dispatchServiceMessage(IOService*ios,const Duration&waitFor,const std::tr1::function<void()>&f){
    std::tr1::shared_ptr<boost::asio::deadline_timer> t(new boost::asio::deadline_timer(*ios,boost::posix_time::microseconds(waitFor.toMicroseconds())));
    using std::tr1::placeholders::_1;
    t->async_wait(std::tr1::bind(&handle_deadline_timer,_1,t,f));
}
开发者ID:MikeSofaer,项目名称:sirikata,代码行数:5,代码来源:IOServiceFactory.cpp


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