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


C++ Milliseconds类代码示例

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


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

示例1: incrementNow

 void NetworkInterfaceMock::incrementNow(Milliseconds inc) {
     boost::lock_guard<boost::mutex> lk(_mutex);
     invariant(inc.total_milliseconds() > 0);
     _now += inc.total_milliseconds();
     _executor->signalWorkForTest();
     _timeElapsed.notify_all();
 }
开发者ID:DieterLutz,项目名称:mongo,代码行数:7,代码来源:network_interface_mock.cpp

示例2: randtime

Milliseconds randtime(Milliseconds const& min, Milliseconds const& max)
{
    long long diff = max.count() - min.count();
    ASSERT(diff >= 0);
    ASSERT(diff <= (uint32)-1);
    return min + Milliseconds(urand(0, diff));
}
开发者ID:DSlayerMan,项目名称:DraenorCore,代码行数:7,代码来源:Random.cpp

示例3: invariant

    Status LegacyReplicationCoordinator::_stepDownHelper(OperationContext* txn,
                                                         bool force,
                                                         const Milliseconds& initialWaitTime,
                                                         const Milliseconds& stepdownTime,
                                                         const Milliseconds& postStepdownWaitTime) {
        invariant(getReplicationMode() == modeReplSet);
        if (!getCurrentMemberState().primary()) {
            return Status(ErrorCodes::NotMaster, "not primary so can't step down");
        }

        if (!force) {
            Status status = _waitForSecondary(initialWaitTime, Milliseconds(10 * 1000));
            if (!status.isOK()) {
                return status;
            }
        }

        // step down
        bool worked = repl::theReplSet->stepDown(txn, stepdownTime.total_seconds());
        if (!worked) {
            return Status(ErrorCodes::NotMaster, "not primary so can't step down");
        }

        if (postStepdownWaitTime.total_milliseconds() > 0) {
            log() << "waiting for secondaries to catch up" << endl;

            // The only caller of this with a non-zero postStepdownWaitTime is
            // stepDownAndWaitForSecondary, and the only caller of that is the shutdown command
            // which doesn't actually care if secondaries failed to catch up here, so we ignore the
            // return status of _waitForSecondary
            _waitForSecondary(postStepdownWaitTime, Milliseconds(0));
        }
        return Status::OK();
    }
开发者ID:QiangTimer,项目名称:mongo,代码行数:34,代码来源:repl_coordinator_legacy.cpp

示例4: roundTime

Date_t roundTime(Date_t now, Milliseconds period) {
    // Note: auto type deduction is explicitly avoided here to ensure rigid type correctness
    long long clock_duration = now.toMillisSinceEpoch();

    long long now_next_period = clock_duration + period.count();

    long long excess_time(now_next_period % period.count());

    long long next_time = now_next_period - excess_time;

    return Date_t::fromMillisSinceEpoch(next_time);
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:12,代码来源:util.cpp

示例5: lk

void NetworkInterfaceASIO::waitForWorkUntil(Date_t when) {
    stdx::unique_lock<stdx::mutex> lk(_executorMutex);
    // TODO: This can be restructured with a lambda.
    while (!_isExecutorRunnable) {
        const Milliseconds waitTime(when - now());
        if (waitTime <= Milliseconds(0)) {
            break;
        }
        _isExecutorRunnableCondition.wait_for(lk, waitTime.toSystemDuration());
    }
    _isExecutorRunnable = false;
}
开发者ID:pk-karthik,项目名称:mongo,代码行数:12,代码来源:network_interface_asio.cpp

示例6: wait

LockResult CondVarLockGrantNotification::wait(Milliseconds timeout) {
    stdx::unique_lock<stdx::mutex> lock(_mutex);
    return _cond.wait_for(
               lock, timeout.toSystemDuration(), [this] { return _result != LOCK_INVALID; })
        ? _result
        : LOCK_TIMEOUT;
}
开发者ID:DINKIN,项目名称:mongo,代码行数:7,代码来源:lock_state.cpp

示例7: sentry

bool Timer::update(const Milliseconds& now)
{
    if(_active == false)
        return false;

    bool hasElapsed = now >= _finished;

    Timer::Sentry sentry(_sentry);

    DateTime ts;

    while( _active && now >= _finished )
    {
        Milliseconds currentTs = _finished;

        // We add another interval before sending the signal
        // since sending might throw an exception. We would
        // skip recalculating the new time then and may loop.
        _finished += _interval;

        if( ! sentry )
            return hasElapsed;

        timeout.send();

        // We send the signal with datetime only, when someone is
        // connected since it will take some time to calculate a
        // DateTime object from milliseconds.
        if (timeoutts.connectionCount() > 0)
        {
            struct tm tim;
            time_t sec = static_cast<time_t>(currentTs.totalSeconds());
            localtime_r(&sec, &tim);
            DateTime dueTime(tim.tm_year + 1900, tim.tm_mon + 1, tim.tm_mday,
                 tim.tm_hour, tim.tm_min, tim.tm_sec,
                 0, currentTs.totalUSecs() % 1000000);
            timeoutts.send(dueTime);
        }

        if (_once)
            stop();
    }

    return hasElapsed;
}
开发者ID:jimklimov,项目名称:cxxtools,代码行数:45,代码来源:timer.cpp

示例8:

DistLockCatalogImpl::DistLockCatalogImpl(RemoteCommandTargeter* targeter,
                                         ShardRegistry* shardRegistry,
                                         Milliseconds writeConcernTimeout)
    : _client(shardRegistry),
      _targeter(targeter),
      _writeConcern(WriteConcernOptions(WriteConcernOptions::kMajority,
                                        WriteConcernOptions::JOURNAL,
                                        writeConcernTimeout.count())),
      _lockPingNS(LockpingsType::ConfigNS),
      _locksNS(LocksType::ConfigNS) {}
开发者ID:aristide,项目名称:mongo,代码行数:10,代码来源:dist_lock_catalog_impl.cpp

示例9: sleepTime

void IgmpSender::threadFunction()
{
    Milliseconds sleepTime(SLEEP_INTERVAL);
    while (!_stopThread) {
        Milliseconds before;

        _igmpPacket->send();

        Milliseconds after;

        after = after - before;

        int slept = after.getTime();
        while (!_stopThread && slept < _interval * 1000) {
            sleepTime.sleep();
            slept += SLEEP_INTERVAL;
        }
    }
}
开发者ID:chubahowsmall,项目名称:ead-cel,代码行数:19,代码来源:IgmpSender.cpp

示例10:

 DistLockCatalogImpl::DistLockCatalogImpl(RemoteCommandTargeter* targeter,
                                          RemoteCommandRunner* executor,
                                          Milliseconds writeConcernTimeout):
     _cmdRunner(executor),
     _targeter(targeter),
     _writeConcern(WriteConcernOptions(WriteConcernOptions::kMajority,
                                       WriteConcernOptions::JOURNAL,
                                       writeConcernTimeout.count())),
     _lockPingNS(LockpingsType::ConfigNS),
     _locksNS(LocksType::ConfigNS) {
 }
开发者ID:EliNok,项目名称:mongo,代码行数:11,代码来源:dist_lock_catalog_impl.cpp

示例11: end

void TimerBase::threadFunction()
{
    Milliseconds begin;
    Milliseconds end(0), diff(0);

    _active = true;
    Interval aux;

    while (_run) {

        aux = _interval - (end - begin);
        end.setTimestamp();
        if (!_run) break;
        Milliseconds(aux).sleep(); // dorme de 5 em 5ms

        begin.setTimestamp();

        if (!_run) break;
        timeout();
        if (_singleShot) break;
    }
    _active = false;
    _run = false;
}
开发者ID:Naykoyan,项目名称:mconf-mobile,代码行数:24,代码来源:Timer.cpp

示例12: shutdown

Status ServiceExecutorReserved::shutdown(Milliseconds timeout) {
    LOG(3) << "Shutting down reserved executor";

    stdx::unique_lock<stdx::mutex> lock(_mutex);
    _stillRunning.store(false);
    _threadWakeup.notify_all();

    bool result = _shutdownCondition.wait_for(lock, timeout.toSystemDuration(), [this]() {
        return _numRunningWorkerThreads.load() == 0;
    });

    return result
        ? Status::OK()
        : Status(ErrorCodes::Error::ExceededTimeLimit,
                 "reserved executor couldn't shutdown all worker threads within time limit.");
}
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:16,代码来源:service_executor_reserved.cpp

示例13: SharedRecursiveLock

      //-----------------------------------------------------------------------
      HTTP::HTTPQuery::HTTPQuery(
                                 const make_private &,
                                 HTTPPtr outer,
                                 IHTTPQueryDelegatePtr delegate,
                                 bool isPost,
                                 const char *userAgent,
                                 const char *url,
                                 const BYTE *postData,
                                 size_t postDataLengthInBytes,
                                 const char *postDataMimeType,
                                 Milliseconds timeout
                                 ) :
        SharedRecursiveLock(outer ? *outer : SharedRecursiveLock::create()),
        MessageQueueAssociator(IHelper::getServiceQueue()),
        mOuter(outer),
        mDelegate(IHTTPQueryDelegateProxy::create(Helper::getServiceQueue(), delegate)),
        mIsPost(isPost),
        mUserAgent(userAgent),
        mURL(url),
        mMimeType(postDataMimeType),
        mTimeout(timeout),
        mStatusCode(HttpStatusCode::None)
      {
        ZS_LOG_DEBUG(log("created"))

        if (0 != postDataLengthInBytes) {
          mPostData.CleanNew(postDataLengthInBytes);
          memcpy(mPostData.BytePtr(), postData, postDataLengthInBytes);
        }

        ZS_EVENTING_8(
                      x, i, Debug, ServicesHttpQueryCreate, os, Http, Start,
                      puid, id, mID,
                      bool, isPost, mIsPost,
                      string, userAgent, mUserAgent,
                      string, url, mURL,
                      buffer, postData, postData,
                      size, postSize, postDataLengthInBytes,
                      string, postDataMimeType, postDataMimeType,
                      duration, timeout, timeout.count()
                      );
      }
开发者ID:openpeer,项目名称:op-services-cpp,代码行数:43,代码来源:services_HTTP_WinRT.cpp

示例14: start

void Timer::start(const DateTime& startTime, const Milliseconds& interval)
{
    if (interval <= Timespan(0))
        throw std::logic_error("cannot run interval timer without interval");

    if (_active)
        stop();
    
    _active = true;
    _interval = interval;
    _once = false;

    Timespan systemTime = Clock::getSystemTicks();
    struct tm tim;
    time_t sec = static_cast<time_t>(systemTime.totalSeconds());
    localtime_r(&sec, &tim);
    DateTime now(tim.tm_year + 1900, tim.tm_mon + 1, tim.tm_mday,
                 tim.tm_hour, tim.tm_min, tim.tm_sec,
                 0, systemTime.totalUSecs() % 1000000);
    if (startTime > now)
    {
        _finished = systemTime + (startTime - now);
    }
    else
    {
        // startTime =< now
        Timespan elapsed = now - startTime;
        uint64_t ticksElapsed = elapsed.totalMSecs() / interval.totalMSecs();
        DateTime tickTime = startTime + (ticksElapsed + 1) * Timespan(interval);
        Timespan delay = tickTime - now;
        _finished = systemTime + (tickTime - now);
    }

    if (_selector)
        _selector->onTimerChanged(*this);
}
开发者ID:jimklimov,项目名称:cxxtools,代码行数:36,代码来源:timer.cpp

示例15: Formatter

	inline void Formatter(FormatData& formatData, const Milliseconds& milliseconds)
	{
		Formatter(formatData, milliseconds.count());

		formatData.string.append(U"ms", 2);
	}
开发者ID:azaika,项目名称:OpenSiv3D,代码行数:6,代码来源:Duration.hpp


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