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


C++ posix_time::time_duration类代码示例

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


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

示例1: force_reannounce

void torrent_handle::force_reannounce(
    boost::posix_time::time_duration duration) const
{
    async_call(&torrent::force_tracker_request, aux::time_now()
               + seconds(duration.total_seconds()), -1);
}
开发者ID:RealImage,项目名称:libtorrent,代码行数:6,代码来源:torrent_handle.cpp

示例2: force_reannounce

	void torrent_handle::force_reannounce(
		boost::posix_time::time_duration duration) const
	{
		INVARIANT_CHECK;
		TORRENT_ASYNC_CALL1(force_tracker_request, time_now() + seconds(duration.total_seconds()));
	}
开发者ID:ABuus,项目名称:libtorrent,代码行数:6,代码来源:torrent_handle.cpp

示例3: getCurrentTime

 unsigned int NetworkActivity::getCurrentTime()
 {
     boost::posix_time::time_duration const diff = boost::posix_time::microsec_clock::local_time() - profilingStart_;
     return diff.total_microseconds();
 }
开发者ID:verbalsaintmars,项目名称:CxxProf,代码行数:5,代码来源:NetworkActivity.cpp

示例4: decay_

inertial::value::value( boost::posix_time::time_duration decay, unsigned int maximum ) : decay_( decay.total_microseconds() ), maximum_( maximum ), value_( 0 ) {}
开发者ID:acfr,项目名称:snark,代码行数:1,代码来源:control-from-console.cpp

示例5: ToSeconds

 static double ToSeconds(const boost::posix_time::time_duration &diff) {
     return diff.total_seconds() + diff.total_nanoseconds() / 1e9;
 }
开发者ID:JunAFa,项目名称:HighPerformanceCharacterString,代码行数:3,代码来源:main.cpp

示例6: datagen_thread_loop

namespace __fwrite__
{

    bool record_thread_running = true;
    bool datagen_thread_running = true;

    #if !defined(WITH_BOOST_TIME)
    timespec ts_beg, ts_end;
    #else
    boost::posix_time::ptime start_time, stop_time;
    boost::posix_time::time_duration time_duration;
    #endif

    vector<long> v_fTime_s;
    vector<long> v_fTime_us;
    vector<float> v_fDifftime;
    float f_DT_s = 0.;

    std::string string_buffer_1, string_buffer_2;
    std::string *active_buffer = &string_buffer_1;

    boost::condition_variable record_trigger;
    boost::mutex mutex;

    const int NUM_LINES = 2e+5;
    bool datagen_done = false;

    /* threat functions*/
    void datagen_thread_loop(void)
    {
        ostringstream testline;

        /* create testdata*/
        int jj=0;
        for(int ii=0; ii < 8*8-1; ii++) //64 = 63 chars + end line
        {
            if(++jj > 9) jj = 0;
            testline << jj;
        }
        testline << "\n";

        jj=0;
        while(record_thread_running && jj < NUM_LINES)
        {
    #if !defined(WITH_BOOST_TIME)
            clock_gettime(CLOCK_MONOTONIC, &ts_beg); // http://linux.die.net/man/3/clock_gettime
    #else
            start_time = boost::posix_time::microsec_clock::local_time();
    #endif

            // ********************************* //
            *active_buffer += testline.str().c_str();
            if(4*1024 < active_buffer->length()) //write 4 kbyte blocks
            {
                record_trigger.notify_all();
            }
            // ********************************* //

    #if !defined(WITH_BOOST_TIME)
            clock_gettime(CLOCK_MONOTONIC, &ts_end);
            v_fTime_s.push_back(ts_end.tv_sec);
            v_fTime_us.push_back(ts_end.tv_nsec/1e+3);
            v_fDifftime.push_back((ts_end.tv_sec - ts_beg.tv_sec)  + (ts_end.tv_nsec - ts_beg.tv_nsec) / 1e9);
            f_DT_s = (ts_end.tv_sec - ts_beg.tv_sec)  + (ts_end.tv_nsec - ts_beg.tv_nsec) / 1e9;
    #else
            stop_time = boost::posix_time::microsec_clock::local_time();
            time_duration = (stop_time - start_time);
            v_fTime_s.push_back( (stop_time-boost::posix_time::from_time_t(0)).total_seconds() );
            v_fTime_us.push_back( (stop_time-boost::posix_time::from_time_t(0)).fractional_seconds() );
            v_fDifftime.push_back( time_duration.total_seconds()+ time_duration.fractional_seconds()/ 1e6);
            f_DT_s = (time_duration.total_seconds()+ time_duration.fractional_seconds()/ 1e6);
    #endif
    #if defined(DEBUG)
            if(0.5 < 1.e+3*f_DT_s) // log only values above 0.5 ms
            {
                cout << "Line " << jj << " of " << NUM_LINES << ":"
                     << "\t" << v_fTime_s.back() << "." << v_fTime_us.back() << "s: "
                     << "\tdT: " << fixed << 1.e+3*f_DT_s << " ms"
                     << endl;
            }
    #endif
            boost::this_thread::sleep(boost::posix_time::microseconds(4*1e+6*f_DT_s)); //about 50% CPU load
            jj++;
        }//while

        datagen_done = true;
    }

    void record_thread_loop(void)
    {
        int buffer_no = 0;

        /* open log file*/
        FILE *logfile = fopen("fwrite_thread_testlog.log","w");
        BOOST_REQUIRE_MESSAGE(logfile != NULL, "Could not open logfile!");

        boost::unique_lock<boost::mutex> lock(mutex);

        while(record_thread_running)
        {
//.........这里部分代码省略.........
开发者ID:Tri-o-copter,项目名称:Brainware,代码行数:101,代码来源:logging_thread_tests.cpp

示例7:

static UHD_INLINE double from_time_dur(const pt::time_duration &time_dur){
    return 1e-6*time_dur.total_microseconds();
}
开发者ID:13572293130,项目名称:uhd,代码行数:3,代码来源:io_impl.cpp

示例8: switch

boost::posix_time::ptime DateTimeEventsManager::GetEventStartTime(const DateTimeEvent* pEvent) const
{
	boost::posix_time::ptime resultTime;

	switch (pEvent->GetType())
	{
	case DateTimeEvent::typeOnce:
		{
			boost::posix_time::ptime scheduledTime(pEvent->GetDate(), pEvent->GetTime());
			const boost::posix_time::time_duration d = boost::posix_time::second_clock::local_time() - scheduledTime;

			// This may happen after player startup if there is an event with date/time in the past.
			if (d.total_seconds() > 1)
			{
				scheduledTime = boost::posix_time::not_a_date_time;
			}

			resultTime = scheduledTime;
		}
		break;

	case DateTimeEvent::typeDaily:
		{
			boost::posix_time::ptime startTime(boost::gregorian::day_clock::local_day(), pEvent->GetTime());
			
			if (boost::posix_time::second_clock::local_time() >= startTime)
				startTime += boost::gregorian::days(1);

			resultTime = startTime;
		}
		break;

	case DateTimeEvent::typeWeekly:
		{
			boost::gregorian::date dateNow(boost::gregorian::day_clock::local_day());

			int currentDayOfWeek = dateNow.day_of_week().as_number();

			if (currentDayOfWeek == 0)
				currentDayOfWeek = 7;

			--currentDayOfWeek; // Format 0 = Mon, 1 = Tue, .. , 6 = Sun
			
			boost::gregorian::date weekStartDate =
				dateNow - boost::gregorian::date_duration(currentDayOfWeek);

			std::vector<boost::posix_time::ptime> times;

			for (int i = 0; i < 7; ++i)
				if (pEvent->GetWeekDays() & (1 << i))
				{
					boost::posix_time::ptime startTime(
						weekStartDate + boost::gregorian::date_duration(i), pEvent->GetTime());

					if (boost::posix_time::second_clock::local_time() >= startTime)
						startTime += boost::gregorian::days(7);

					times.push_back(startTime);
				}

			std::sort(times.begin(), times.end());

			_ASSERTE(!times.empty());
			resultTime = times[0];
		}
		break;
	}

	return resultTime;
}
开发者ID:andrewsmolko,项目名称:foo_scheduler,代码行数:70,代码来源:date_time_events_manager.cpp

示例9: set_connect_timeout

void curl::set_connect_timeout(const boost::posix_time::time_duration& timeout)
{
    set_option(CURLOPT_CONNECTTIMEOUT_MS, timeout.total_milliseconds());
}
开发者ID:reaper,项目名称:libfreelan,代码行数:4,代码来源:curl.cpp

示例10: averageTimePerFrameUpdated

void AutomaticGraphicsLevelManager::averageTimePerFrameUpdated(const boost::posix_time::time_duration timePerFrame)
{
	//Convert microseconds per frame to fps.
	checkFps(1000000.0f / timePerFrame.total_microseconds());
}
开发者ID:Chimangoo,项目名称:ember,代码行数:5,代码来源:AutoGraphicsLevelManager.cpp

示例11: run

void run( S* stream )
{
    static const unsigned int timeSize = 12;
    boost::mt19937 generator;
    boost::uniform_real< float > distribution( 0, 1 );
    boost::variate_generator< boost::mt19937&, boost::uniform_real< float > > random( generator, distribution );
    comma::uint64 count = 0;
    comma::uint64 dropped_count = 0;
    double compression = 0;
    velodyne::packet packet;
    comma::signal_flag isShutdown;
    velodyne::scan_tick tick;
    comma::uint32 scan_id = 0;
    while( !isShutdown && std::cin.good() && !std::cin.eof() && std::cout.good() && !std::cout.eof() )
    {
        const char* p = velodyne::impl::stream_traits< S >::read( *stream, sizeof( velodyne::packet ) );
        if( p == NULL ) { break; }
        ::memcpy( &packet, p, velodyne::packet::size );
        if( tick.is_new_scan( packet ) ) { ++scan_id; } // quick and dirty
        boost::posix_time::ptime timestamp = stream->timestamp();
        if( scan_rate ) { scan.thin( packet, *scan_rate, angularSpeed( packet ) ); }
        if( !scan_rate || !scan.empty() )
        {
            if( focus ) { velodyne::thin::thin( packet, *focus, *db, angularSpeed( packet ), random ); }
            if( rate ) { velodyne::thin::thin( packet, *rate, random ); }
        }
        const boost::posix_time::ptime base( snark::timing::epoch );
        const boost::posix_time::time_duration d = timestamp - base;
        comma::int64 seconds = d.total_seconds();
        comma::int32 nanoseconds = static_cast< comma::int32 >( d.total_microseconds() % 1000000 ) * 1000;
        if( outputRaw ) // real quick and dirty
        {
            static boost::array< char, 16 + timeSize + velodyne::packet::size + 4 > buf;
            static const boost::array< char, 2 > start = {{ -78, 85 }}; // see QLib::Bytestreams::GetDefaultStartDelimiter()
            static const boost::array< char, 2 > end = {{ 117, -97 }}; // see QLib::Bytestreams::GetDefaultStartDelimiter()
            ::memcpy( &buf[0], &start[0], 2 );
            ::memcpy( &buf[0] + buf.size() - 2, &end[0], 2 );
            ::memcpy( &buf[0] + 16, &seconds, 8 );
            ::memcpy( &buf[0] + 16 + 8, &nanoseconds, 4 );
            ::memcpy( &buf[0] + 16 + 8 + 4, &packet, velodyne::packet::size );
            if( publisher ) { publisher->write( &buf[0], buf.size() ); }
            else if( publisher_udp_socket ) { publisher_udp_socket->send_to( boost::asio::buffer( &buf[0], buf.size() ), udp_destination ); }
            else { std::cout.write( &buf[0], buf.size() ); }
        }
        else
        {
            // todo: certainly rewrite with the proper header using comma::packed
            static char buf[ timeSize + sizeof( comma::uint16 ) + velodyne::thin::maxBufferSize ];
            comma::uint16 size = velodyne::thin::serialize( packet, buf + timeSize + sizeof( comma::uint16 ), scan_id );
            bool empty = size == ( sizeof( comma::uint32 ) + 1 ); // todo: atrocious... i.e. packet is not empty; refactor!!!
            if( !empty )
            {
                size += timeSize;
                ::memcpy( buf, &size, sizeof( comma::uint16 ) );
                size += sizeof( comma::uint16 );
                ::memcpy( buf + sizeof( comma::uint16 ), &seconds, sizeof( comma::int64 ) );
                ::memcpy( buf + sizeof( comma::uint16 ) + sizeof( comma::int64 ), &nanoseconds, sizeof( comma::int32 ) );
                if( publisher ) { publisher->write( buf, size ); }
                else if( publisher_udp_socket ) { publisher_udp_socket->send_to( boost::asio::buffer( buf, size ), udp_destination ); }
                else { std::cout.write( buf, size ); }
            }
            else
            {
                ++dropped_count;
            }
            if( verbose )
            {
                ++count;
                compression = 0.9 * compression + 0.1 * ( empty ? 0.0 : double( size + sizeof( comma::int16 ) ) / ( velodyne::packet::size + timeSize ) );
                if( count % 10000 == 0 ) { std::cerr << "velodyne-thin: processed " << count << " packets; dropped " << ( double( dropped_count ) * 100. / count ) << "% full packets; compression rate " << compression << std::endl; }
            }
        }
    }
    if( publisher ) { publisher->close(); }
    std::cerr << "velodyne-thin: " << ( isShutdown ? "signal received" : "no more data" ) << "; shutdown" << std::endl;
}
开发者ID:WangFei-DUT,项目名称:snark,代码行数:76,代码来源:velodyne-thin.cpp

示例12: Truncate

 /*!
   \param time The time point to truncate.
   \param unit The unit of time to truncate the time point to.
   \return The time point truncated to the specified <i>unit</i>.
 */
 inline boost::posix_time::ptime Truncate(const boost::posix_time::ptime& time,
     boost::posix_time::time_duration unit) {
   return time - boost::posix_time::microseconds(
     time.time_of_day().total_microseconds() % unit.total_microseconds());
 }
开发者ID:eidolonsystems,项目名称:beam,代码行数:10,代码来源:TimeClient.hpp

示例13: CalculateSpeed

double CalculateSpeed(long long bytes, const boost::posix_time::time_duration& duration)
{
  double seconds = duration.total_microseconds() / 1000000.0;
  return seconds == 0.0 ? bytes : bytes / seconds;
}
开发者ID:glftpd,项目名称:ebftpd,代码行数:5,代码来源:util.cpp

示例14: purge

/**
 * @brief Purge cache entries that have not been active for some time.
 *
 * @param  indom   Instance domain to purge entries for.
 * @param  recent  All entries that have not been active within this interval
 *                 will be purged.
 *
 * @throw  pcp::exception  On error.
 *
 * @return The number of items purged.
 *
 * @see pmdaCachePurge
 */
inline size_t purge(const pmInDom indom, const boost::posix_time::time_duration &recent)
{
    return purge(indom, recent.total_seconds());
}
开发者ID:bchoi,项目名称:pcp-pmda-cpp,代码行数:17,代码来源:cache.hpp

示例15: force_reannounce

	void torrent_handle::force_reannounce(
		boost::posix_time::time_duration duration) const
	{
		TORRENT_ASYNC_CALL2(force_tracker_request, aux::time_now()
			+ seconds(duration.total_seconds()), -1);
	}
开发者ID:aresch,项目名称:libtorrent,代码行数:6,代码来源:torrent_handle.cpp


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