这篇教程C++ time_point函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中time_point函数的典型用法代码示例。如果您正苦于以下问题:C++ time_point函数的具体用法?C++ time_point怎么用?C++ time_point使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了time_point函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: time_point steady_clock::time_point steady_clock::now(system::error_code & ec) { timespec ts; if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) ) { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( system::system_error( errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::steady_clock" )); } else { ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY ); return time_point(); } } if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } return time_point(duration( static_cast<steady_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec)); }
开发者ID:AsgeirSH,项目名称:Client,代码行数:27,
示例2: time_pointprocess_cpu_clock::time_point process_cpu_clock::now( system::error_code & ec ) { tms tm; clock_t c = ::times( &tm ); if ( c == clock_t(-1) ) // error { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( system::system_error( errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock" )); } else { ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY ); return time_point(); } } else { if ( chrono_detail::tick_factor() != -1 ) { time_point::rep r( c*chrono_detail::tick_factor(), (tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(), (tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor()); return time_point(duration(r)); } else { if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( system::system_error( errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock" )); } else { ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY ); return time_point(); } } } }
开发者ID:AVCProject,项目名称:AVC,代码行数:52,
示例3: assertprocess_cpu_clock::time_point process_cpu_clock::now( system::error_code & ec ) { // note that Windows uses 100 nanosecond ticks for FILETIME boost::detail::win32::FILETIME_ creation, exit, user_time, system_time; #ifdef UNDER_CE // Windows CE does not support GetProcessTimes assert( 0 && "GetProcessTimes not supported under Windows CE" ); return time_point(); #else if ( boost::detail::win32::GetProcessTimes( boost::detail::win32::GetCurrentProcess(), &creation, &exit, &system_time, &user_time ) ) { if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } time_point::rep r( steady_clock::now().time_since_epoch().count(), ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32) | user_time.dwLowDateTime ) * 100, ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32) | system_time.dwLowDateTime ) * 100 ); return time_point(duration(r)); } else { boost::detail::win32::DWORD_ cause = boost::detail::win32::GetLastError(); if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( system::system_error( cause, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_cpu_clock" )); } else { ec.assign( cause, BOOST_CHRONO_SYSTEM_CATEGORY ); return time_point(); } } #endif}
开发者ID:AVCProject,项目名称:AVC,代码行数:51,
示例4: time_pointprocess_cpu_clock::time_point process_cpu_clock::now( system::error_code & ec ){ tms tm; clock_t c = ::times( &tm ); if ( c == clock_t(-1) ) // error { if (::boost::chrono::is_throws(ec)) { boost::throw_exception( system::system_error( errno, ::boost::system::system_category(), "chrono::process_clock" )); } else { ec.assign( errno, ::boost::system::system_category() ); return time_point(); } } else { if ( chrono_detail::tick_factor() != -1 ) { time_point::rep r( c*chrono_detail::tick_factor(), (tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(), (tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor()); return time_point(duration(r)); } else { if (::boost::chrono::is_throws(ec)) { boost::throw_exception( system::system_error( errno, ::boost::system::system_category(), "chrono::process_clock" )); } else { ec.assign( errno, ::boost::system::system_category() ); return time_point(); } } }}
开发者ID:betajippity,项目名称:Nuparu,代码行数:50,
示例5: push /*! Retroactively insert an element to the end of the queue just before * some time point by moving it. * /param t The time point of the operation just before this new one. * /param val The value to move. * /return A new time point representing this retroactive operation. */ time_point push(const time_point &t, T&& val) { inner_iterator it = t.it; if (it == data_.begin()) { // Inserting before the first element is a special case data_.push_front(std::make_pair(std::move(val), true)); move_front_pred(); } else if (it == front_) { // Inserting before the front is also a special case data_.insert(front_, std::make_pair(std::move(val), false)); } else { // Whether this element is before the front pointer is determined // by the element before this one. inner_iterator before = std::prev(it); data_.insert(it, std::make_pair(std::move(val), before->second)); } // Point iterator to the newly inserted element. --it; ++size_; // Move the front to the left if this operation is before the front // because we pushed an element that should've been popped before. if (it->second) move_front_pred(); // Return an iterator to the new operation. return time_point(std::move(it), queue::push); }
开发者ID:ebnn,项目名称:retro,代码行数:38,
示例6: whilevoid ExternalOutput::sendLoop() { while (recording_) { boost::unique_lock<boost::mutex> lock(mtx_); cond_.wait(lock); while (audio_queue_.hasData()) { boost::shared_ptr<DataPacket> audio_packet = audio_queue_.popPacket(); writeAudioData(audio_packet->data, audio_packet->length); } while (video_queue_.hasData()) { boost::shared_ptr<DataPacket> video_packet = video_queue_.popPacket(); writeVideoData(video_packet->data, video_packet->length); } if (!inited_ && first_data_received_ != time_point()) { inited_ = true; } } // Since we're bailing, let's completely drain our queues of all data. while (audio_queue_.getSize() > 0) { boost::shared_ptr<DataPacket> audio_packet = audio_queue_.popPacket(true); // ignore our minimum depth check writeAudioData(audio_packet->data, audio_packet->length); } while (video_queue_.getSize() > 0) { boost::shared_ptr<DataPacket> video_packet = video_queue_.popPacket(true); // ignore our minimum depth check writeVideoData(video_packet->data, video_packet->length); }}
开发者ID:rhinobird,项目名称:licode,代码行数:27,
示例7: rprocess_cpu_clock::time_point process_cpu_clock::now( system::error_code & ec ){ // note that Windows uses 100 nanosecond ticks for FILETIME autoboost::detail::winapi::FILETIME_ creation, exit, user_time, system_time; if ( autoboost::detail::winapi::GetProcessTimes( autoboost::detail::winapi::GetCurrentProcess(), &creation, &exit, &system_time, &user_time ) ) { if (!AUTOBOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } time_point::rep r(process_real_cpu_clock::now().time_since_epoch().count() , ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32) | user_time.dwLowDateTime ) * 100, ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32) | system_time.dwLowDateTime ) * 100 ); return time_point(duration(r)); } else { autoboost::detail::winapi::DWORD_ cause = autoboost::detail::winapi::GetLastError(); if (AUTOBOOST_CHRONO_IS_THROWS(ec)) { autoboost::throw_exception( system::system_error( cause, AUTOBOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_cpu_clock" )); } else { ec.assign( cause, AUTOBOOST_CHRONO_SYSTEM_CATEGORY ); return time_point(); } }}
开发者ID:c-zheng,项目名称:autowiring,代码行数:45,
示例8: QueryPerformanceCounterHighResTimer::time_point HighResTimer::now() { LARGE_INTEGER n_ticks, ticks_per_second; QueryPerformanceCounter(&n_ticks); QueryPerformanceFrequency(&ticks_per_second); // Avoid precision loss long long tmp = n_ticks.QuadPart * static_cast<rep>(period::den); // Return the number of microseconds return time_point(duration(tmp / ticks_per_second.QuadPart));}
开发者ID:lieff,项目名称:GIGL,代码行数:9,
示例9: switchstd::tm datetime::gmtime() const{ imgtool_clock::time_point tp; switch (type()) { case datetime_type::GMT: tp = time_point(); break; case datetime_type::LOCAL: tp = time_point() - s_gmt_offset; break; default: tp = imgtool_clock::time_point(); break; } return imgtool_clock::to_tm(tp);}
开发者ID:MASHinfo,项目名称:mame,代码行数:18,
示例10: now static time_point now() {#if defined(BOOST_HAS_CLOCK_GETTIME) time_point t; ::clock_gettime(CLOCK_REALTIME, &t.m_value); return t;#else return time_point(::time(0));#endif }
开发者ID:vbudovski,项目名称:thread,代码行数:10,
示例11: whileconst MonsterGroup &MonsterGroupManager::GetUpgradedMonsterGroup( const mongroup_id &group ){ const MonsterGroup *groupptr = &group.obj(); if( get_option<float>( "MONSTER_UPGRADE_FACTOR" ) > 0 ) { const time_duration replace_time = groupptr->monster_group_time * get_option<float>( "MONSTER_UPGRADE_FACTOR" ); while( groupptr->replace_monster_group && calendar::turn - time_point( calendar::start ) > replace_time ) { groupptr = &groupptr->new_monster_group.obj(); } } return *groupptr;}
开发者ID:CleverRaven,项目名称:Cataclysm-DDA,代码行数:13,
示例12: time_pointprocess_system_cpu_clock::time_point process_system_cpu_clock::now( system::error_code & ec){ // note that Windows uses 100 nanosecond ticks for FILETIME boost::detail::win32::FILETIME_ creation, exit, user_time, system_time; if ( boost::detail::win32::GetProcessTimes( boost::detail::win32::GetCurrentProcess(), &creation, &exit, &system_time, &user_time ) ) { if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } return time_point(duration( ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32) | system_time.dwLowDateTime) * 100 )); } else { boost::detail::win32::DWORD_ cause = boost::detail::win32::GetLastError(); if (BOOST_CHRONO_IS_THROWS(ec)) { boost::throw_exception( system::system_error( cause, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_system_cpu_clock" )); } else { ec.assign( cause, BOOST_CHRONO_SYSTEM_CATEGORY ); return time_point(); } }}
开发者ID:AKinanS,项目名称:Server,代码行数:39,
示例13: QueryPerformanceFrequencyQPCClock::time_point QPCClock::now() { static LARGE_INTEGER freq; // Use this dummy local static to ensure this gets initialized once. static BOOL dummy = QueryPerformanceFrequency(&freq); LARGE_INTEGER ticks; QueryPerformanceCounter(&ticks); // This is prone to overflow when multiplying, which is why I'm using micro instead of nano. The // correct way to approach this would be to just return ticks as a time_point and then subtract // and do this conversion when creating a duration from two time_points, however, as far as I // could tell the C++ requirements for these types are incompatible with this approach. return time_point(duration(ticks.QuadPart * std::micro::den / freq.QuadPart));}
开发者ID:GTO888,项目名称:citra,代码行数:14,
示例14: bool benchmark::State::UpdateTimer(const benchmark::time_point current_time){ if (m_start_time != time_point()) { std::chrono::duration<double> diff = current_time - m_start_time; m_elapsed_results.push_back(diff.count() / m_num_iters); if (m_elapsed_results.size() == m_num_evals) { return false; } } m_num_iters_left = m_num_iters - 1; return true;}
开发者ID:machinecoin-project,项目名称:machinecoin-core,代码行数:14,
示例15: time_point process_system_cpu_clock::time_point process_system_cpu_clock::now(system::error_code & ec) { tms tm; clock_t c = ::times(&tm); if (c == clock_t(-1)) // error { if (BOOST_CHRONO_IS_THROWS(ec)) { pdalboost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_system_cpu_clock")); } else { ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY); return time_point(); } } else { long factor = chrono_detail::tick_factor(); if (factor != -1) { if (!BOOST_CHRONO_IS_THROWS(ec)) { ec.clear(); } return time_point(nanoseconds((tm.tms_stime + tm.tms_cstime) * factor)); } else { if (BOOST_CHRONO_IS_THROWS(ec)) { pdalboost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_system_cpu_clock")); } else { ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY); return time_point(); } } } }
开发者ID:AsherBond,项目名称:PDAL,代码行数:37,
示例16: check_updates_workerstatic void* check_updates_worker(void* arg){ timing_info timing; reset_timing(&timing); while(!stop){ start_timing(&timing); if(!updated && push_commit){ if(push_commit){ pthread_mutex_lock(&commit_mutex); if(push_result_shell(push_commit, NULL)){ puts("Failed to push coin, reseting."); pthread_mutex_lock(&update_mutex); fetch_updates(); updated = 1; pthread_mutex_unlock(&update_mutex); } else { puts("Earned it!"); } push_commit = NULL; pthread_mutex_unlock(&commit_mutex); } else { if(check_updates()){ pthread_mutex_lock(&update_mutex); updated = 1; pthread_mutex_unlock(&update_mutex); } } time_point(&timing); print_timing(&timing); } else { skip_point(&timing); usleep(10); } } puts("Update thread ending"); pthread_exit(NULL);}
开发者ID:Posnet,项目名称:gpu-cuda,代码行数:45,
示例17: query_windows_performance_counter windows_performance_counter_clock::time_point flut::windows_performance_counter_clock::now() { long long count = query_windows_performance_counter() - g_epoch; return time_point( duration( count * static_cast< rep >( period::den ) / g_frequency ) ); }
开发者ID:tgeijten,项目名称:flut,代码行数:5,
示例18: time_point friend time_point operator - ( const time_point_sec& t, const microseconds& m ) { return time_point(t) - m; }
开发者ID:VicHao,项目名称:fc,代码行数:1,
示例19: now static time_point now() { return time_point(duration(SIMIX_get_clock())); }
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:4,
示例20: maximum static time_point maximum() { return time_point( microseconds::maximum() ); }
开发者ID:VicHao,项目名称:fc,代码行数:1,
示例21: QueryPerformanceCountertimer::HighResClock::time_point timer::HighResClock::now() { LARGE_INTEGER count; QueryPerformanceCounter(&count); return time_point(duration(count.QuadPart * static_cast<rep>(period::den) / g_Frequency));}
开发者ID:Cigg,项目名称:Voxel-Cone-Tracing,代码行数:5,
示例22: mainint main (int argc, char **argv) { git_index *index = NULL; pthread_t updateThread, hashThread; int rc, difficulty; void *status; hash_args args; timing_info timing; git_oid curr_commit; reset_timing(&timing); pthread_mutex_init(&commit_mutex, NULL); pthread_mutex_init(&update_mutex, NULL); push_commit = NULL; difficulty = init_args(&args); init_git(&index); init_hasher(difficulty); check_updates(); reset_hard(); puts("Starting update thread"); rc = pthread_create(&updateThread, NULL, check_updates_worker, NULL); if (rc){ printf("ERROR creating update thread %d/n", rc); exit(-1); } signal (SIGINT, int_handler); while(!stop){ start_timing(&timing); args.found = 0; time_point(&timing); pthread_mutex_lock(&commit_mutex); pthread_mutex_lock(&update_mutex); if(updated){ reset_hard(); updated = 0; push_commit = NULL; } pthread_mutex_unlock(&update_mutex); pthread_mutex_unlock(&commit_mutex); time_point(&timing); puts("Preparing index"); prepare_index(index, args.msg); time_point(&timing); puts("Starting brute force thread"); rc = pthread_create(&hashThread, NULL, force_hash, &args); time_point(&timing); if (rc){ printf("ERROR creating hash thread %d/n", rc); stop = 1; } else { pthread_join(hashThread, &status); } time_point(&timing); if(!stop && !updated && args.found){ puts("Found one!"); while(push_commit){ usleep(10); } time_point(&timing); if(!stop && !updated){ pthread_mutex_lock(&commit_mutex); commit_result(args.msg, &curr_commit); push_commit = &curr_commit; pthread_mutex_unlock(&commit_mutex); } } else { puts("Reset while looking for a hash"); time_point(&timing); } time_point(&timing); print_timing(&timing); } pthread_join(updateThread, &status); free_hasher(); free(args.msg);//.........这里部分代码省略.........
开发者ID:Posnet,项目名称:gpu-cuda,代码行数:101,
示例23: min static time_point min() { return time_point(); }
开发者ID:VicHao,项目名称:fc,代码行数:1,
示例24: queueDatavoid ExternalOutput::queueData(char* buffer, int length, packetType type) { if (!recording_) { return; } RtcpHeader *head = reinterpret_cast<RtcpHeader*>(buffer); if (head->isRtcp()) { return; } if (first_data_received_ == time_point()) { first_data_received_ = clock::now(); if (getAudioSinkSSRC() == 0) { ELOG_DEBUG("No audio detected"); audio_map_ = RtpMap{0, "PCMU", 8000, AUDIO_TYPE, 1}; audio_codec_ = AV_CODEC_ID_PCM_MULAW; } } if (need_to_send_fir_ && video_source_ssrc_) { sendFirPacket(); need_to_send_fir_ = false; } if (type == VIDEO_PACKET) { RtpHeader* h = reinterpret_cast<RtpHeader*>(buffer); uint8_t payloadtype = h->getPayloadType(); if (video_offset_ms_ == -1) { video_offset_ms_ = ClockUtils::durationToMs(clock::now() - first_data_received_); ELOG_DEBUG("File %s, video offset msec: %llu", context_->filename, video_offset_ms_); video_queue_.setTimebase(video_maps_[payloadtype].clock_rate); } // If this is a red header, let's push it to our fec_receiver_, which will spit out frames in one // of our other callbacks. // Otherwise, just stick it straight into the video queue. if (payloadtype == RED_90000_PT) { // The only things AddReceivedRedPacket uses are headerLength and sequenceNumber. // Unfortunately the amount of crap // we would have to pull in from the WebRtc project to fully construct // a webrtc::RTPHeader object is obscene. So // let's just do this hacky fix. webrtc::RTPHeader hacky_header; hacky_header.headerLength = h->getHeaderLength(); hacky_header.sequenceNumber = h->getSeqNumber(); // AddReceivedRedPacket returns 0 if there's data to process if (0 == fec_receiver_->AddReceivedRedPacket(hacky_header, (const uint8_t*)buffer, length, ULP_90000_PT)) { fec_receiver_->ProcessReceivedFec(); } } else { video_queue_.pushPacket(buffer, length); } } else { if (audio_offset_ms_ == -1) { audio_offset_ms_ = ClockUtils::durationToMs(clock::now() - first_data_received_); ELOG_DEBUG("File %s, audio offset msec: %llu", context_->filename, audio_offset_ms_); // Let's also take a moment to set our audio queue timebase. RtpHeader* h = reinterpret_cast<RtpHeader*>(buffer); if (h->getPayloadType() == PCMU_8000_PT) { audio_queue_.setTimebase(8000); } else if (h->getPayloadType() == OPUS_48000_PT) { audio_queue_.setTimebase(48000); } } audio_queue_.pushPacket(buffer, length); } if (audio_queue_.hasData() || video_queue_.hasData()) { // One or both of our queues has enough data to write stuff out. Notify our writer. cond_.notify_one(); }}
开发者ID:rhinobird,项目名称:licode,代码行数:74,
注:本文中的time_point函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ time_stamp函数代码示例 C++ time_now_d函数代码示例 |