本文整理汇总了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
}
示例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));
}
示例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();
}
示例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));
}
示例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));
}
示例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));
}