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


C++ Duration类代码示例

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


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

示例1: do_wait

 void do_wait(const Duration& timeout, pdalboost::system::error_code& ec)
 {
   ::timeval tv;
   tv.tv_sec = timeout.total_seconds();
   tv.tv_usec = timeout.total_microseconds() % 1000000;
   socket_ops::select(0, 0, 0, 0, &tv, ec);
 }
开发者ID:GeospatialDaryl,项目名称:PDAL,代码行数:7,代码来源:deadline_timer_service.hpp

示例2: random_sort

int COpenTest::delete_random(BonTimer &timer)
{
  random_sort(timer.random_source);
  timer.start();
  int i;
  Duration dur;
  for(i = 0; i < m_number; i++)
  {
    dur.start();
    if(unlink(m_file_names[i]))
    {
      fprintf(stderr, "Can't delete file %s\n", m_file_names[i]);
      return -1;
    }
    if(m_sync && m_sync_dir)
    {
      if(fsync(m_directoryHandles[m_dirIndex[i]]))
      {
        fprintf(stderr, "Can't sync directory, turning off dir-sync.\n");
        m_sync_dir = false;
      }
    }
    dur.stop();
  }
  if(m_number_directories > 1)
  {
    char buf[6];
    for(i = 0; i < m_number_directories; i++)
    {
      sprintf(buf, "%05d", i);
      if(m_sync)
      {
        close(m_directoryHandles[i]);
      }
      if(rmdir(buf))
      {
        io_error("rmdir");
        return -1;
      }
    }
  }
  else
  {
    if(m_sync)
    {
      close(m_directoryHandles[0]);
    }
  }
  if(chdir("..") || rmdir(m_dirname))
  {
    io_error("rmdir");
    return -1;
  }
  delete m_dirname;
  m_dirname = NULL;
  sync();
  timer.stop_and_record(DelRand);
  timer.add_latency(DelRand, dur.getMax());
  return 0;
}
开发者ID:azat-archive,项目名称:bonnie,代码行数:60,代码来源:bon_file.cpp

示例3: Duration

void Odometry_new::run()
{
  scout_position = node.advertise< ::messages::ScoutPosition>(name+"/posn", 1000);
  double last_time = Time::now().toSec();
  double loop_time, current_time;

  // Reset encoders.
  encoders->reset();

  //Rate r(LOOP_RATE); 
  Duration r = Duration(LOOP_TIME);

  motors->set_sides(-50,50, MOTOR_ABSOLUTE);

  while(ok())
  {
    current_time = Time::now().toSec();
    loop_time = current_time - last_time;
    last_time = current_time;

    get_position(loop_time);
    ROS_INFO("loop time %f", loop_time);

    position.name = name;
    position.x = scout_pos->x;
    position.y = scout_pos->y;
    position.theta = scout_pos->theta;
    scout_position.publish(position);

    ROS_INFO("scout is at %f %f theta: %f", position.x, position.y, position.theta);

    r.sleep();
  }
}
开发者ID:CMU-Robotics-Club,项目名称:Colony,代码行数:34,代码来源:Odometry_new.cpp

示例4: createMeasure

void Lilypond::addNote(const LNote& lnote)
      {
      createMeasure();

      Segment* segment = new Segment(measure);
      segment->setSubtype(SegChordRest);
      segment->setTick(tick);
      segment->setParent(measure);
      measure->add(segment);

      Chord* chord = new Chord(score);
      chord->setTrack(staff->idx() * VOICES);
      chord->setParent(segment);
      Duration d;
      d.setVal(lnote.len);
      chord->setDurationType(d);

      segment->add(chord);

      Note* note = new Note(score);
      note->setPitch(lnote.pitch);
      note->setTpcFromPitch();
      note->setParent(chord);
      note->setTrack(staff->idx() * VOICES);
      chord->add(note);
      tick += lnote.len;
      }
开发者ID:SSMN,项目名称:MuseScore,代码行数:27,代码来源:lilypond.cpp

示例5: glShaderSource

bool Shader::compile(const char* source)
{
    _compilationDuration = 0;
    GlError error;

    if (source[0] == '\0')
    {
        _lastCompilationLog = "Shader source is empty!";
        return false;
    }

    glShaderSource(_shaderId, 1, &source, NULL);
    if (error.hasOccured())
    {
        _lastCompilationLog = error.toString("Error while attaching source to shader (glShaderSource)");
        return false;
    }

    Duration duration;
    glCompileShader(_shaderId);
    _compilationDuration= duration.elapsed();
    if (error.hasOccured())
    {
        _lastCompilationLog = error.toString("Error while compiling shader (glCompileShader)");
        return false;
    }

    GLint compilationSucceeded = GL_FALSE;
    glGetShaderiv(_shaderId, GL_COMPILE_STATUS, &compilationSucceeded);

    extractInfoLog();

    return compilationSucceeded == GL_TRUE;
}
开发者ID:spoonless,项目名称:shadercreator,代码行数:34,代码来源:shader.cpp

示例6: SetCurrentTime

void
Clock::Begin (TimeSpan parentTime)
{
	//printf ("clock %p (%s) begin\n", this, GetName ());
	emit_completed = false;
	has_completed = false;
	was_stopped = false;

	/* we're starting.  initialize our current_time field */
	SetCurrentTime ((parentTime - root_parent_time - timeline->GetBeginTime ()) * timeline->GetSpeedRatio());

	Duration d = GetNaturalDuration ();
	if (d.HasTimeSpan ()) {
		if (d.GetTimeSpan() == 0) {
			progress = 1.0;
		}
		else {
			progress = (double)current_time / d.GetTimeSpan();
			if (progress > 1.0)
				progress = 1.0;
		}
	}
	else
		progress = 0.0;

	CalculateFillTime ();

	SetClockState (Clock::Active);

	// force the time manager to tick the clock hierarchy to wake it up
	time_manager->NeedClockTick ();
}
开发者ID:kangaroo,项目名称:moon,代码行数:32,代码来源:clock.cpp

示例7: generate

  void generate()
  {
    watch.start();

    while (true) {
      Duration elapsed = watch.elapsed();

      if (duration.isSome() && elapsed >= duration.get()) {
        LOG(INFO) << "LoadGenerator generated " << messages
                  << " messages in " << elapsed << " (throughput = "
                  << (messages / elapsed.secs()) << " messages/sec)";

        LOG(INFO) << "Stopping LoadGenerator and scheduler driver";

        terminate(self());
        driver->stop();
        return;
      }

      Stopwatch reconcile;
      reconcile.start();

      driver->reconcileTasks(vector<TaskStatus>());

      messages++;

      // Compensate for the driver call overhead.
      os::sleep(std::max(
          Duration::zero(),
          Seconds(1) / qps - reconcile.elapsed()));
    }
  }
开发者ID:GrovoLearning,项目名称:mesos,代码行数:32,代码来源:load_generator_framework.cpp

示例8: isDuration

////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::duration
//   <ISO8106p> | <Duration>
bool Lexer::isDuration (std::string& token, Lexer::Type& type)
{
  std::size_t marker = _cursor;
  ISO8601p iso;

  std::string extractedToken;
  Lexer::Type extractedType;
  if (isOperator(extractedToken, extractedType))
  {
    _cursor = marker;
    return false;
  }

  marker = 0;
  if (iso.parse (_text.substr (_cursor), marker))
  {
    type = Lexer::Type::duration;
    token = _text.substr (_cursor, marker);
    _cursor += marker;
    return true;
  }

  Duration dur;
  if (dur.parse (_text.substr (_cursor), marker))
  {
    type = Lexer::Type::duration;
    token = _text.substr (_cursor, marker);
    _cursor += marker;
    return true;
  }

  return false;
}
开发者ID:lowfatcomputing,项目名称:task,代码行数:36,代码来源:Lexer.cpp

示例9: TEST

TEST(DurationTest, AssignSubtract) {
    Duration d = Duration::fromSeconds(5);
    Duration d2 = Duration::fromSeconds(10);
    d -= d2;

    EXPECT_EQ(-5, d.toIntegerSeconds());
    EXPECT_EQ(10, d2.toIntegerSeconds());
}
开发者ID:DJMaxergy,项目名称:mixxx,代码行数:8,代码来源:duration_test.cpp

示例10: resetMapUpdateTimer

void ElevationMapping::resetMapUpdateTimer()
{
  mapUpdateTimer_.stop();
  Duration periodSinceLastUpdate = Time::now() - map_.getTimeOfLastUpdate();
  if (periodSinceLastUpdate > maxNoUpdateDuration_) periodSinceLastUpdate.fromSec(0.0);
  mapUpdateTimer_.setPeriod(maxNoUpdateDuration_ - periodSinceLastUpdate);
  mapUpdateTimer_.start();
}
开发者ID:amiltonwong,项目名称:elevation_mapping,代码行数:8,代码来源:ElevationMapping.cpp

示例11: tgr

void TestUnpackRowLength::TestAndOutput(int aNumIterations, FILE* aFile)
{
  TestGLRunner tgr(this);
  Duration d = tgr.Run(aNumIterations);
  OutputTestName(aFile);
  fprintf(aFile, ",%d,%d,%d,%d,%d,%.0f\n", mPixelSize, mTextureSize, mAlignment,
          mUploadWidth, mOffset, d.ToMilliseconds());
}
开发者ID:alijuma,项目名称:GLMeasure,代码行数:8,代码来源:TestGL.cpp

示例12: main

int main( int argc, char *argv[] )
{
	const Clock::time_point start = Clock::now();

	std::cout << "called with: " << std::endl << "\t";
	for ( int i = 0; i < argc; ++i ) {
		std::cout << argv[i] << " ";
	}
	std::cout << std::endl;

	po::options_description desc( "testRDIS options" );

	try {
		addOptions( desc );

		po::variables_map options;
		po::store( po::parse_command_line( argc, argv, desc ), options );

		po::notify( options );

		if ( options.count( "help" ) ) {
			std::cout << desc << std::endl;

		} else {
			std::vector<string> files;

			if ( options.count( "file" ) ) {
				// get the set of files to optimize
				const std::vector<string> tmpf =
						options["file"].as< std::vector<string> >();
				files.assign( tmpf.begin(), tmpf.end() );
			}

			if ( files.empty() ) {
				// run the pre-defined debug tests
				run_debug_test( options );

			} else {
				// optimize each input polynomial
				for ( string file : files ) {
					optimize_poly( file, options );
				}
			}
		}

	} catch ( const std::exception & e ) {
		std::cerr << "Exception occurred in main: \n\t" << e.what() << std::endl;
	} catch ( const std::string & s ) {
		std::cerr << "Exception occurred in main: \n\t" << s << std::endl;
	} catch ( const char * c ) {
		std::cerr << "Exception occurred in main: \n\t" << c << std::endl;
	}

	const Duration elapsed = Clock::now() - start;
	std::cout << "total elapsed time: " << elapsed.count() << " seconds" << std::endl;

	return 0;
}
开发者ID:Cloud2016,项目名称:rdis,代码行数:58,代码来源:main.cpp

示例13: clientTimeOffset

Time ObjectHost::localTime(const SpaceID& space, const Time& t) {
    Duration off = clientTimeOffset(space);
    // FIXME we should probably return a negative time and force the code using
    // this (e.g. the loc update stuff) to make sure it handles it correctly by
    // extrapolating to a current time.
    // This is kinda gross, but we need to make sure result >= 0
    if ( (int64)t.raw() + off.toMicro() < 0) return Time::null();
    return t + off;
}
开发者ID:SinSiXX,项目名称:sirikata,代码行数:9,代码来源:ObjectHost.cpp

示例14: main

int main( int argc, const char * const argv[] )
{
	BOOSTNS::random::mt19937 rng( 834725927 );
	const Clock::time_point start = Clock::now();

	std::cout << "called with: " << std::endl << "\t";
	for ( int i = 0; i < argc; ++i ) {
		std::cout << argv[i] << " ";
	}
	std::cout << std::endl;

	po::options_description desc( "Bundle Adjustment options" );

	try {
		addOptions( desc );

		po::variables_map options;
		po::store( po::parse_command_line( argc, argv, desc ), options );

//		po::parsed_options parsed =
//				po::command_line_parser( argc, argv ).options( desc ).allow_unregistered().run();
//		po::store( parsed, vm );
//		std::vector< string > to_pass_further =
//				po::collect_unrecognized( parsed.options, po::exclude_positional );

		po::notify( options );

		if ( options.count( "help" ) ) {
			std::cout << desc << std::endl;

		} else if ( !options.count( "file" ) ) {
			std::cout << "\nat least one input BA file must be specified\n" << std::endl;
			std::cout << desc << std::endl;

		} else {
			// get the set of files to optimize
			const std::vector< string > files =
					options[ "file" ].as< std::vector< string > >();

			// optimize each one
			for ( string file : files ) {
				optimize_BA( rng, options, file );
			}
		}

	} catch ( po::error & e) {
		  std::cerr << "\nCommand line error: " << e.what() << std::endl << std::endl;
		  std::cerr << desc << std::endl;
	} catch ( std::exception & e ) {
		std::cerr << "\nException occurred in main (B.A. opt): \n\t" << e.what()
				<< ", application will now exit. Goodbye!" << std::endl;
	}

	const Duration elapsed = Clock::now() - start;
	std::cout << "total elapsed time: " << elapsed.count() << " seconds" << std::endl;
}
开发者ID:Cloud2016,项目名称:rdis,代码行数:56,代码来源:optBA.cpp

示例15: get

 double get(const Time& t, double K) const {
     Duration diff = t - _t;
     double dt = diff.toSeconds();
     if (dt<1.0e-9) {
         return _value;
     }
     double blend = exp(-dt/K);
     uint32 new_bytes = _backlog;
     return _value*blend+(1-blend)*new_bytes/dt;
 }
开发者ID:Waqee,项目名称:sirikata,代码行数:10,代码来源:RateEstimator.hpp


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