• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TimePoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TEST

TEST(EventBaseTest, RunInThread) {
  uint32_t numThreads = 50;
  uint32_t opsPerThread = 100;
  RunInThreadData data(numThreads, opsPerThread);

  deque<std::thread> threads;
  for (uint32_t i = 0; i < numThreads; ++i) {
    threads.emplace_back([i, &data] {
        for (int n = 0; n < data.opsPerThread; ++n) {
          RunInThreadArg* arg = new RunInThreadArg(&data, i, n);
          data.evb.runInEventBaseThread(runInThreadTestFunc, arg);
          usleep(10);
        }
      });
  }

  // Add a timeout event to run after 3 seconds.
  // Otherwise loop() will return immediately since there are no events to run.
  // Once the last thread exits, it will stop the loop().  However, this
  // timeout also stops the loop in case there is a bug performing the normal
  // stop.
  data.evb.tryRunAfterDelay(std::bind(&EventBase::terminateLoopSoon, &data.evb),
                         3000);

  TimePoint start;
  data.evb.loop();
  TimePoint end;

  // Verify that the loop exited because all threads finished and requested it
  // to stop.  This should happen much sooner than the 3 second timeout.
  // Assert that it happens in under a second.  (This is still tons of extra
  // padding.)

  auto timeTaken = std::chrono::duration_cast<milliseconds>(
    end.getTime() - start.getTime());
  ASSERT_LT(timeTaken.count(), 1000);
  VLOG(11) << "Time taken: " << timeTaken.count();

  // Verify that we have all of the events from every thread
  int expectedValues[numThreads];
  for (uint32_t n = 0; n < numThreads; ++n) {
    expectedValues[n] = 0;
  }
  for (deque< pair<int, int> >::const_iterator it = data.values.begin();
       it != data.values.end();
       ++it) {
    int threadID = it->first;
    int value = it->second;
    ASSERT_EQ(expectedValues[threadID], value);
    ++expectedValues[threadID];
  }
  for (uint32_t n = 0; n < numThreads; ++n) {
    ASSERT_EQ(expectedValues[n], opsPerThread);
  }

  // Wait on all of the threads.
  for (auto& thread: threads) {
    thread.join();
  }
}
开发者ID:NextGenIntelligence,项目名称:folly,代码行数:60,代码来源:EventBaseTest.cpp


示例2: TEST

// instanciate and play with gates
TEST(ALibxx, ChronoTest){

    using namespace Davix::Chrono;

    TimePoint pp;
    ASSERT_EQ(0, pp.toTimestamp());

    pp = Clock(Clock::Monolitic).now();
    TimePoint copy_time = pp;
    ASSERT_EQ(pp, copy_time);
    copy_time = copy_time + Duration(5);
    ASSERT_NE(copy_time, pp);
    ASSERT_EQ(copy_time, pp + Duration(5));
    ASSERT_GE(copy_time, pp);
    ASSERT_GE(copy_time, pp + Duration(5));
    ASSERT_GT(copy_time, pp);
    ASSERT_LE(copy_time, pp + Duration(5));
    ASSERT_LE(copy_time, pp + Duration(10));
    ASSERT_LT(copy_time, pp + Duration(10));

    ASSERT_EQ(copy_time + Duration(5), pp + Duration(10));

    copy_time = pp;
    ASSERT_EQ(copy_time, pp + Duration(10) - Duration(20) + Duration(10));

    TimePoint dd;
    ASSERT_ANY_THROW(
                 Duration res = dd - pp;
                );
开发者ID:cern-it-sdc-id,项目名称:davix,代码行数:30,代码来源:chrono.cpp


示例3: printSpatialEntities

// Print the spatial entities corresponding to the given time point and of the requested type
void printSpatialEntities(TimePoint &timePoint, const SubsetSpecificType &spatialEntityType) {
    for (auto it = timePoint.getSpatialEntitiesBeginIterator(spatialEntityType);
         it != timePoint.getSpatialEntitiesEndIterator(spatialEntityType); it++) {
        std::cout << "\t SpatialEntity" << std::endl;

        std::cout << (*(*it)).toString() << std::endl;
    }
}
开发者ID:,项目名称:,代码行数:9,代码来源:


示例4:

void
SpatialTemporalDataReader::setTimePointValue(const pt::ptree &timePointTree, TimePoint &timePoint) {
    double timePointValue;

    if (timePointHasValue(timePointTree, timePointValue)) {
        timePoint.setValue(timePointValue);
    } else {
        timePoint.setValue(std::numeric_limits<double>::max());
    }
}
开发者ID:,项目名称:,代码行数:10,代码来源:


示例5: ofGetElapsedTimef

void TimeLine::addPoint(ofPoint _pos){
    
    if ( (startTime == -1) || (points.size() == 0) ){
        startTime = ofGetElapsedTimef();
    } 
    
    TimePoint newPoint;
    newPoint.set(_pos);
    newPoint.time = ofGetElapsedTimef() - startTime;
    
    points.push_back( newPoint );
}
开发者ID:jeonghopark,项目名称:patriciogv_avsys2013,代码行数:12,代码来源:TimeLine.cpp


示例6: getTimeDiffInMinute

int TimePoint::getTimeDiffInMinute(const TimePoint &another) const
{
    int diff = convertToMinute() - another.convertToMinute();
    if(diff < 0)
        diff = -diff;
    return diff;
}
开发者ID:HMLONG,项目名称:uva-online-judge-solutions,代码行数:7,代码来源:UVA10191.cpp


示例7: getMeanAndStdErrorEndPoint

//---------------------------------------------------------------------------
void getMeanAndStdErrorEndPoint(const std::vector<TimeSeries>& timeSeries, TimePoint& mean, TimePoint& stdError)
{
    assert(mean.isNull()==true);
    assert(stdError.isNull()==true);

    //Only set: biasA, biasB, fractionMixedPairs

    const unsigned int nTimeSeries = timeSeries.size();
    for (unsigned i=0; i<nTimeSeries; ++i)
    {
        //Get the index of the final index
        const unsigned int time = timeSeries[i].timePoints.size() - 1;
        mean += timeSeries[i].timePoints[time];
    }
    mean/=nTimeSeries;
}
开发者ID:RLED,项目名称:ProjectRichelBilderbeek,代码行数:17,代码来源:UnitTimeSeries.cpp


示例8: setAnimationTime

    inline void setAnimationTime(const TimePoint& timePoint) {
        if (mode == MapMode::Still) {
            return;
        }

        animationTime = timePoint.time_since_epoch();
    };
开发者ID:nagyistoce,项目名称:mapbox-gl-native,代码行数:7,代码来源:map_data.hpp


示例9: timeSeed

static inline int32 timeSeed()
{
	using namespace chrono;
	static int32 count = 0;

	typedef high_resolution_clock::time_point TimePoint;

	typedef TimePoint::duration Duration;

	TimePoint now = high_resolution_clock::now();
	Duration sinceEpoch = now.time_since_epoch();
	seconds secs = duration_cast<seconds>(sinceEpoch);

	nanoseconds nsecs = sinceEpoch - secs;

	return (int32)secs.count() ^ (int32)nsecs.count() ^ count--;
}
开发者ID:DSastre,项目名称:supercollider,代码行数:17,代码来源:SC_Time.hpp


示例10: printTimePoint

// Print the given time point
void printTimePoint(TimePoint &timePoint) {
    std::cout << "Time point " << timePoint.getValue() << std::endl;

    for (std::size_t i = 0; i < NR_SUBSET_SPECIFIC_TYPES; i++) {
        std::cout << "Subset specific type " << i << ": " << std::endl;

        printSpatialEntities(timePoint, subsetspecific::computeSubsetSpecificType(i));
    }
}
开发者ID:,项目名称:,代码行数:10,代码来源:


示例11:

const synfig::Node::time_set	& ValueNode_DynamicList::ListEntry::get_times() const
{
	synfig::ActivepointList::const_iterator 	j = timing_info.begin(),
											end = timing_info.end();

	//must remerge with all the other values because we don't know if we've changed...
	times = value_node->get_times();

	for(; j != end; ++j)
	{
		TimePoint t;
		t.set_time(j->get_time());
		t.set_guid(j->get_guid());

		times.insert(t);
	}

	return times;
}
开发者ID:ChillyCider,项目名称:synfig-reloaded,代码行数:19,代码来源:valuenode_dynamiclist.cpp


示例12: OSCTime

static inline int64 OSCTime(TimePoint const & tp)
{
	using namespace chrono;
	typedef typename TimePoint::duration Duration;
	Duration sinceEpoch = tp.time_since_epoch();
	seconds secs = duration_cast<seconds>(sinceEpoch);

	nanoseconds nsecs = sinceEpoch - secs;

	return ((int64)(secs.count() + kSECONDS_FROM_1900_to_1970) << 32)
			+ (int64)(nsecs.count() * kNanosToOSCunits);
}
开发者ID:DSastre,项目名称:supercollider,代码行数:12,代码来源:SC_Time.hpp


示例13: createDerivedSpatialEntity

void
SpatialTemporalDataReader::addSpatialEntityToTimePoint(const pt::ptree &spatialEntityTree,
                                                       TimePoint &timePoint) {
    std::shared_ptr<SpatialEntity>  spatialEntity;
    SubsetSpecificType              spatialEntityType;

    createDerivedSpatialEntity(spatialEntityTree, spatialEntity, spatialEntityType);
    setSpatialEntityScaleAndSubsystem(spatialEntityTree, spatialEntity);
    setSpatialEntityMeasureValues(spatialEntityTree, spatialEntity);

    timePoint.addSpatialEntityAndType(spatialEntity, spatialEntityType);
}
开发者ID:,项目名称:,代码行数:12,代码来源:


示例14: addNumericStateVariablesToTimePoint

void TemporalDataReader::addNumericStateVariablesToTimePoint(const std::vector<std::string> &lineTokens,
                                                             TimePoint &timePoint) {
    std::size_t nrOfTokens = lineTokens.size();

    for (std::size_t i = 1; i < nrOfTokens; i++) {
        double observableVariableValue = StringManipulator::convert<double>(lineTokens[i]);

        timePoint.addNumericStateVariable(
            numericStateVariableIds[i],
            observableVariableValue
        );
    }
}
开发者ID:,项目名称:,代码行数:13,代码来源:


示例15:

jobject mdr::JniStationPrediction::createJniStationPrediction(JNIEnv *env,
                                                              TimePoint timePoint,
                                                              float value,
                                                              std::string timeZone) {
    auto duration = timePoint.time_since_epoch();
    auto epoch = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
    jlong jniEpoch = static_cast<jlong>(epoch);
    jobject jniValue = mdr::JniFloat::toJni(env, value);
    jstring tz = mdr::JniString::toJni(env, timeZone);
    auto retVal = env->CallStaticObjectMethod(stationPredictionFactoryClass, factoryCtor, jniEpoch,
                                              tz, jniValue);
    mdr::Jni::checkException(env, true);
    return retVal;
}
开发者ID:manimaul,项目名称:AndXtideLib,代码行数:14,代码来源:JniStationPrediction.cpp


示例16: checkTimeout

bool checkTimeout(
    const TimePoint& start,
    const TimePoint& end,
    nanoseconds expected,
    bool allowSmaller,
    nanoseconds tolerance) {
  auto elapsedTime = end.getTimeStart() - start.getTimeEnd();

  if (!allowSmaller) {
    // Timeouts should never fire before the time was up.
    // Allow 1ms of wiggle room for rounding errors.
    if (elapsedTime < (expected - milliseconds(1))) {
      return false;
    }
  }

  // Check that the event fired within a reasonable time of the timout.
  //
  // If the system is under heavy load, our process may have had to wait for a
  // while to be run.  The time spent waiting for the processor shouldn't
  // count against us, so exclude this time from the check.
  nanoseconds timeExcluded;
  if (end.getTid() != start.getTid()) {
    // We can only correctly compute the amount of time waiting to be scheduled
    // if both TimePoints were set in the same thread.
    timeExcluded = nanoseconds(0);
  } else {
    timeExcluded = end.getTimeWaiting() - start.getTimeWaiting();
    assert(end.getTimeWaiting() >= start.getTimeWaiting());
    // Add a tolerance here due to precision issues on linux, see below note.
    assert((elapsedTime + tolerance) >= timeExcluded);
  }

  nanoseconds effectiveElapsedTime(0);
  if (elapsedTime > timeExcluded) {
    effectiveElapsedTime = elapsedTime - timeExcluded;
  }

  // On x86 Linux, sleep calls generally have precision only to the nearest
  // millisecond.  The tolerance parameter lets users allow a few ms of slop.
  auto overrun = effectiveElapsedTime - expected;
  if (overrun > tolerance) {
    return false;
  }

  return true;
}
开发者ID:Orvid,项目名称:folly,代码行数:47,代码来源:TimeUtil.cpp


示例17: numericStateVariableId

void
SpatialTemporalDataReader::addNumericStateVariableToTimePoint(const pt::ptree &numericStateVariableTree,
                                                              TimePoint &timePoint) {
    std::string name
        = numericStateVariableTree.get<std::string>(LABEL_NUMERIC_STATE_VARIABLE_NAME);
    boost::optional<std::string> scaleAndSubsystem
        = numericStateVariableTree.get_optional<std::string>(LABEL_NUMERIC_STATE_VARIABLE_SCALE_AND_SUBSYSTEM);
    double value
        = numericStateVariableTree.get<double>(LABEL_NUMERIC_STATE_VARIABLE_VALUE);

    NumericStateVariableId numericStateVariableId(
        name,
        scaleAndSubsystem.get_value_or(ScaleAndSubsystem::DEFAULT_VALUE)
    );

    timePoint.addNumericStateVariable(numericStateVariableId, value);
}
开发者ID:,项目名称:,代码行数:17,代码来源:


示例18: readMDXVelocityField

void readMDXVelocityField(const string &filename, TimePoint &timePoint, const Mesh3d &mesh, double time) {
    ifstream input(filename);
    double unusedTime; //TODO: Should this be thrown out?
    input >> unusedTime; // unused
    if (time != unusedTime) {
        cout << "Warning: File " << filename << " Specifies time " << unusedTime << ", using " << time << " instead." << endl;
    }
    timePoint.time = time;
    timePoint.resize(mesh.points.size());
    cout << "Reading velocities from " << filename << endl;
    readMDXPoints(timePoint.velocities, input, mesh.points.size());
    cout<<" Velocities were read succesfully "  <<endl;
    calculateVorticityMesh(mesh, timePoint);
    cout<<" Vorticities were calculated succesfully "  <<endl;
#ifdef DUMP_MSH
    writeMshFile(filename + "_out.msh", mesh, timePoint);
    cout<<" Dumped msh file to " << filename << "_out.msh" << endl;
#endif
}
开发者ID:jcperezma,项目名称:Mechanistic-Model-cplusplus,代码行数:19,代码来源:Moldex+3D+flow+field+utilities.cpp


示例19: setTimePointValue

void TemporalDataReader::setTimePointValue(const std::vector<std::string> &lineTokens,
                                           TimePoint &timePoint) {
    double timePointValue = StringManipulator::convert<double>(lineTokens[0]);

    timePoint.setValue(timePointValue);
}
开发者ID:,项目名称:,代码行数:6,代码来源:


示例20: secondsSinceEpoch

static inline double secondsSinceEpoch(TimePoint const & tp)
{
	return chrono::duration_cast<chrono::nanoseconds>(tp.time_since_epoch()).count() * 1e-9;
}
开发者ID:DSastre,项目名称:supercollider,代码行数:4,代码来源:SC_Time.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TimeRange类代码示例发布时间:2022-05-31
下一篇:
C++ TimeOut类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap