本文整理汇总了C++中TimerPtr类的典型用法代码示例。如果您正苦于以下问题:C++ TimerPtr类的具体用法?C++ TimerPtr怎么用?C++ TimerPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimerPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_timer_callback
/**
* \brief Executes the callback of a timer.
*
* Then, if the callback returns \c true, the timer is rescheduled,
* otherwise it is discarded.
*
* Does nothing if the timer is already finished.
*
* \param timer The timer to execute.
*/
void LuaContext::do_timer_callback(const TimerPtr& timer) {
Debug::check_assertion(timer->is_finished(), "This timer is still running");
auto it = timers.find(timer);
if (it != timers.end() &&
!it->second.callback_ref.is_empty()) {
ScopedLuaRef& callback_ref = it->second.callback_ref;
push_ref(l, callback_ref);
const bool success = call_function(0, 1, "timer callback");
bool repeat = false;
if (success) {
repeat = lua_isboolean(l, -1) && lua_toboolean(l, -1);
lua_pop(l, 1);
}
if (repeat) {
// The callback returned true: reschedule the timer.
timer->set_expiration_date(timer->get_expiration_date() + timer->get_initial_duration());
if (timer->is_finished()) {
// Already finished: this is possible if the duration is smaller than
// the main loop stepsize.
do_timer_callback(timer);
}
}
else {
callback_ref.clear();
timers_to_remove.push_back(timer);
}
}
}
开发者ID:benoitschneider,项目名称:solarus,代码行数:42,代码来源:TimerApi.cpp
示例2: DataCachePtr
void Bagger::buildTree(){
int treeId;
// Choose tree id
m_chooseTree->lock();
treeId = m_treeId++;
m_chooseTree->unlock();
// sorting is performed inside this constructor
DataCachePtr myData = DataCachePtr(new DataCache(m_data,m_evaluation,m_seed));
// create the in-bag dataset (and be sure to remember what's in bag)
// for computing the out-of-bag error later
DataCachePtr bagData = myData->resample(m_bagSize);
/*bagData.reusableRandomGenerator = bagData.getRandomNumberGenerator(
random.nextInt());*/
m_inBag[treeId] = bagData->inBag;
// build the classifier
RandomTreePtr aTree = m_trees[treeId];
aTree->data = bagData;
TimerPtr timer = TimerPtr(new boost::timer);
aTree->build();
double time = timer->elapsed();
m_chooseTree->lock();
m_buildTime += time;
m_totalNumNodes += aTree->getNumNodes();
m_chooseTree->unlock();
}
开发者ID:KarlJansson,项目名称:GPU_tree-ensembles,代码行数:30,代码来源:Bagger.cpp
示例3: earliest_expire_time
long EventLoop::earliest_expire_time()
{
TimerPtr timer = timer_heap_.top();
if (!timer)
return -1;
long delay = timer->expire_msec() - current_msec_;
return (delay > 0) ? delay : 0;
}
开发者ID:jiangzw,项目名称:gazellemq,代码行数:8,代码来源:event_loop.cpp
示例4: GetTimer
bool Time::ResumeTimer(const UInt& _uTimerID)
{
TimerPtr pTimer = GetTimer(_uTimerID);
bool bResult = (NULL != pTimer);
if (false != bResult)
{
bResult = pTimer->Resume();
}
return bResult;
}
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:12,代码来源:Time.cpp
示例5: findParent
TimerPtr
Dashboard::getTimer(const std::string & theName) {
std::map<std::string,TimerPtr>::iterator found = _myTimers.find(theName);
if (found == _myTimers.end()) {
TimerPtr myParent = findParent();
TimerPtr myNewTimer = TimerPtr(new Timer(myParent));
_myTimers[theName] = myNewTimer;
myNewTimer->setName(theName);
_mySortedTimers.push_back(std::make_pair(theName, myNewTimer));
return myNewTimer;
}
return found->second;
}
开发者ID:artcom,项目名称:asl,代码行数:13,代码来源:Dashboard.cpp
示例6: run
void Timer::run(TaskContextPtr taskContextPtr, const boost::system::error_code& e){
if(e == boost::asio::error::operation_aborted){
return ;
}
taskContextPtr->func_();
if(taskContextPtr->mode == 1){
TimerPtr timerPtr = taskContextPtr->timerPtr_;
timerPtr->expires_at(timerPtr->expires_at() + boost::posix_time::millisec(taskContextPtr->deadline_time));
timerPtr->async_wait(taskContextPtr->strand_.wrap(bind(&Timer::run, this, taskContextPtr, placeholders::error)));
}else{
}
}
开发者ID:xiaoyu-real,项目名称:Test,代码行数:13,代码来源:Timer.cpp
示例7: getProfiler
void GraphIO::loadNodes(const YAML::Node& doc, SemanticVersion version)
{
TimerPtr timer = getProfiler()->getTimer("load graph");
YAML::Node nodes = doc["nodes"];
if (nodes.IsDefined()) {
for (std::size_t i = 0, total = nodes.size(); i < total; ++i) {
const YAML::Node& n = nodes[i];
auto interlude = timer->step(n["uuid"].as<std::string>());
loadNode(n, version);
}
}
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:14,代码来源:graphio.cpp
示例8: ProcessTimer
void RunLoop::ProcessTimer(TimerPtr timer)
{
if ( timer->IsCancelled() )
{
RemoveTimer(timer);
return;
}
timer->_fn(*timer); // DO CALLOUT
if ( !timer->Repeats() || timer->IsCancelled() )
{
RemoveTimer(timer);
}
}
开发者ID:desoohn,项目名称:readium-sdk,代码行数:15,代码来源:run_loop_windows.cpp
示例9: handle_timer_events
int EventLoop::handle_timer_events()
{
if (expired_timers_.empty())
return 0;
// handle single timer
TimerPtr timer = expired_timers_.front();
expired_timers_.pop_front();
thread_pool_->promote_new_leader();
if (timer->repeat()) {
timer->reset(current_msec_);
timer_heap_.schedule(timer);
}
timer->handle_timeout(current_msec_);
return 1;
}
开发者ID:jiangzw,项目名称:gazellemq,代码行数:16,代码来源:event_loop.cpp
示例10: onTimer
//-------------------------------------------------------------------------
void RTPReceiverChannelAudio::onTimer(TimerPtr timer)
{
ZS_LOG_DEBUG(log("timer") + ZS_PARAM("timer id", timer->getID()))
AutoRecursiveLock lock(*this);
#define TODO 1
#define TODO 2
}
开发者ID:odmanV2,项目名称:ortc-lib,代码行数:9,代码来源:ortc_RTPReceiverChannelAudio.cpp
示例11: monitorBegin
void TimerMonitor::monitorBegin(TimerPtr timer)
{
AutoRecursiveLock lock(mLock);
if (!mThread) {
mThread = ThreadPtr(new boost::thread(boost::ref(*getTimerMonitor().get())));
}
PUID timerID = timer->getID();
mMonitoredTimers[timerID] = TimerWeakPtr(timer);
wakeUp();
}
开发者ID:,项目名称:,代码行数:12,代码来源:
示例12: CreateTimer
UInt Time::CreateTimer(const bool _bStart)
{
bool bResult = true;
TimerPtrVec::iterator iTimer = m_vpTimers.begin();
TimerPtrVec::iterator iEnd = m_vpTimers.end();
TimerPtr pTimer = NULL;
UInt uResult = 0;
while (iEnd != iTimer)
{
if (false == (*iTimer)->m_bIsActive)
{
pTimer = *iTimer;
break;
}
++iTimer;
++uResult;
}
if (NULL == pTimer)
{
pTimer = new Timer(m_lTicksPerSeconds);
m_vpTimers.push_back(pTimer);
}
if (false == _bStart)
{
float fTemp;
bResult = ResetTimer(uResult, fTemp) && PauseTimer(uResult);
}
if (false == bResult)
{
pTimer->Release();
uResult = 0xffffffff;
}
return uResult;
}
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:40,代码来源:Time.cpp
示例13: pthread_setname_np
void TimerMonitor::operator()()
{
bool shouldShutdown = false;
#ifndef _LINUX
pthread_setname_np("com.zslib.timer");
#endif
do
{
Duration duration;
// wait completed, do notifications from select
{
AutoRecursiveLock lock(mLock);
shouldShutdown = mShouldShutdown;
duration = fireTimers();
}
boost::unique_lock<boost::mutex> flagLock(mFlagLock);
mFlagNotify.timed_wait<Duration>(flagLock, duration);
// notify all those timers needing to be notified
} while (!shouldShutdown);
{
AutoRecursiveLock lock(mLock);
// go through timers and cancel them completely
for (TimerMap::iterator monIter = mMonitoredTimers.begin(); monIter != mMonitoredTimers.end(); ) {
TimerMap::iterator current = monIter;
++monIter;
TimerPtr timer = current->second.lock();
if (timer)
timer->background(false);
}
mMonitoredTimers.clear();
}
}
开发者ID:,项目名称:,代码行数:40,代码来源:
示例14: printTimers
void
Dashboard::printTimers(Table & theTable, TimerPtr theParent, const std::string & theIndent) {
for (unsigned i = 0; i < _mySortedTimers.size(); ++i) {
std::string & myTimerName = _mySortedTimers[i].first;
TimerPtr myTimerPtr = _mySortedTimers[i].second;
if (myTimerPtr->getParent() == theParent) {
theTable.addRow();
theTable.setField("timername", theIndent + myTimerName);
unsigned long myCycleCount = _myGroupCounters[myTimerPtr->getGroup()].getCount();
if (myCycleCount) {
const asl::Timer & myTimer = _myCompleteCycleTimers[myTimerName];
theTable.setField("elapsed",as_string((double)(myTimer.getElapsed().micros())/1000.0/myCycleCount));
const asl::Counter & myCounter = myTimer.getCounter();
if (myCounter.getCount()>1) {
theTable.setField("intervals",as_string((myCounter.getCount()+1.0)/myCycleCount));
theTable.setField("persec",as_string(myCounter.getCount()/myTimer.getElapsed().seconds()));
theTable.setField("average",as_string(myTimer.getElapsed().micros()/1000.0/myCounter.getCount()));
theTable.setField("minimum",as_string(myTimer.getMin().micros()/1000.0));
theTable.setField("maximum",as_string(myTimer.getMax().micros()/1000.0));
theTable.setField("cycles",as_string(myCycleCount));
}
} else {
const asl::Timer & myTimer = *myTimerPtr;
const asl::Counter & myCounter = myTimer.getCounter();
theTable.setField("elapsed",as_string((double)(myTimer.getElapsed().micros())/1000.0));
if (myCounter.getCount()>1) {
theTable.setField("intervals",as_string(myCounter.getCount()));
theTable.setField("persec",as_string(myCounter.getCount()/myTimer.getElapsed().seconds()));
theTable.setField("average",as_string(myTimer.getElapsed().micros()/1000.0));
}
theTable.setField("cycles","incomplete");
}
printTimers(theTable, myTimerPtr, theIndent+" ");
}
}
}
开发者ID:artcom,项目名称:asl,代码行数:38,代码来源:Dashboard.cpp
示例15: Register
void TimeManager::Register(TimerPtr pTimer,TimerStop bStop )
{
uint64 nTime;
mpTime->Get(nTime);
TimerDataPtr ptd = new TimerData;
ptd->pTimer = pTimer;
ptd->nLastTime = nTime + pTimer->GetInterval();
ptd->bStop = bStop;
mTimeDatas.push_back(ptd);
}
开发者ID:satanupup,项目名称:epb,代码行数:14,代码来源:jge_timemanager.cpp
示例16: lock
Duration TimerMonitor::fireTimers()
{
AutoRecursiveLock lock(mLock);
Time time = boost::posix_time::microsec_clock::universal_time();
Duration duration = boost::posix_time::seconds(1);
for (TimerMap::iterator monIter = mMonitoredTimers.begin(); monIter != mMonitoredTimers.end(); )
{
TimerMap::iterator current = monIter;
++monIter;
TimerPtr timer = (current->second).lock();
bool done = true;
if (timer)
done = timer->tick(time, duration);
if (done)
mMonitoredTimers.erase(current);
}
return duration;
}
开发者ID:,项目名称:,代码行数:24,代码来源:
示例17: scheduleRepeated
void TaskManager::scheduleRepeated(const TimerPtr& timer) {
_scheduler->scheduleRepeated(timer, IceUtil::Time::milliSeconds(timer->delay()));
}
开发者ID:,项目名称:,代码行数:3,代码来源:
示例18: calculateMaxNodes
void GPUERT::deviceHandler(){
m_devId = m_gfxMgr->createDeviceContext(m_devId);
calculateMaxNodes(m_devId);
initResources();
m_constantsBagging.cb_baggingActivated = false;
TimerPtr timerKernel = TimerPtr(new boost::timer);
TimerPtr timer = TimerPtr(new boost::timer);
TimerPtr timerTotal = TimerPtr(new boost::timer);
m_internalNodes = 0, m_leafNodes = 0;
int treesLeft = m_numTrees;
int treesToLaunch = m_maxTreesPerIteration;
int lastLaunch = 0;
int checkSum = m_maxTreesPerIteration;
int newNodes = m_maxTreesPerIteration;
std::vector<int> checkVars(4,0);
m_buildTime = 0;
m_baggingTime = 0;
m_classificationTime = 0;
m_depth = 0;
timerTotal->restart();
int numIter = ceil(float(m_numTrees)/float(m_maxTreesPerIteration));
for(unsigned int j=0; j<numIter; ++j){
checkSum = treesToLaunch;
newNodes = treesToLaunch;
m_constants.cb_nodeBufferStart = 0;
m_constants.cb_nodeIdFlip = 0;
initResourceBatch(lastLaunch == treesToLaunch);
lastLaunch = treesToLaunch;
treesLeft -= treesToLaunch;
timer->restart();
for(unsigned int i=0; i<m_MaxDepth; ++i){
if(i > m_depth)
m_depth = i;
assert(newNodes < m_maxNodesPerIteration);
int nodeLimit = 10000;
int innerNodes = newNodes;
int numInnerIter = ceil(float(innerNodes)/float(nodeLimit));
int launchCount = 0;
m_constants.cb_availableNodes = newNodes;
m_constants.cb_numFeatures = 0;
timerKernel->restart();
for(unsigned int k=0; k<m_numFeatures; ++k){
innerNodes = newNodes;
numInnerIter = ceil(float(innerNodes)/float(nodeLimit));
launchCount = 0;
// Best split kernel
m_gfxMgr->setGPUBuffer(m_devId,m_setBufferIdsExFindSplit,m_setResourceTypesExFindSplit);
m_gfxMgr->setGPUProgram(m_devId,m_gpuFunctionIds["RFP_ExFindSplit"]);
innerNodes = newNodes;
launchCount = 0;
m_constants.cb_currentDepth = 0;
for(unsigned int l=0; l<numInnerIter; ++l){
launchCount = innerNodes > nodeLimit ? nodeLimit : innerNodes;
m_gfxMgr->copyToGPU(m_devId,m_bufferIds["RFB_constants"],&ConstantUpdate(&m_constants,KID_ExtremeFindSplit),sizeof(m_constants));
m_gfxMgr->launchComputation(m_devId,launchCount*thread_group_size,1,1);
m_constants.cb_currentDepth += launchCount;
innerNodes -= launchCount;
if(innerNodes <= 0)
break;
}
++m_constants.cb_numFeatures;
}
if(m_kernelSpecificTimings){
m_gfxMgr->syncDevice(m_devId);
m_kernelTimes[L"RFP_ExFindSplit"] += timerKernel->elapsed();
}
innerNodes = newNodes;
launchCount = 0;
m_constants.cb_currentDepth = 0;
m_gfxMgr->setGPUBuffer(m_devId,m_setBufferIdsExMakeSplit,m_setResourceTypesExMakeSplit);
m_gfxMgr->setGPUProgram(m_devId,m_gpuFunctionIds["RFP_ExMakeSplit"]);
// Split data
timerKernel->restart();
for(unsigned int k=0; k<numInnerIter; ++k){
launchCount = innerNodes > nodeLimit ? nodeLimit : innerNodes;
m_gfxMgr->copyToGPU(m_devId,m_bufferIds["RFB_constants"],&ConstantUpdate(&m_constants,KID_ExtremeMakeSplit),sizeof(m_constants));
m_gfxMgr->launchComputation(m_devId,launchCount*thread_group_size,1,1);
m_constants.cb_currentDepth += launchCount;
innerNodes -= launchCount;
if(innerNodes <= 0)
break;
}
if(m_kernelSpecificTimings){
//.........这里部分代码省略.........
开发者ID:KarlJansson,项目名称:GPU_tree-ensembles,代码行数:101,代码来源:GPUERT.cpp
示例19: destroy
void Timer::destroy(int id)
{
TimerPtr timer = city::Timers::instance().find( id );
if( timer.isValid() )
timer->destroy();
}
开发者ID:dalerank,项目名称:caesaria-game,代码行数:6,代码来源:timer.cpp
示例20: Timer
void
TimerPriorityTest::run()
{
#ifdef _WIN32
//
// Test to create a timer with a given priority
//
try
{
TimerPtr t = new Timer(THREAD_PRIORITY_IDLE);
t->destroy();
t = new Timer(THREAD_PRIORITY_LOWEST);
t->destroy();
t = new Timer(THREAD_PRIORITY_BELOW_NORMAL);
t->destroy();
t = new Timer(THREAD_PRIORITY_NORMAL);
t->destroy();
t = new Timer(THREAD_PRIORITY_ABOVE_NORMAL);
t->destroy();
t = new Timer(THREAD_PRIORITY_HIGHEST);
t->destroy();
t = new Timer(THREAD_PRIORITY_TIME_CRITICAL);
t->destroy();
}
catch(...)
{
test(false);
}
//
// Test to create a timer with priorities too high
//
try
{
TimerPtr t = new Timer(THREAD_PRIORITY_TIME_CRITICAL + 10);
test(false);
}
catch(const ThreadSyscallException&)
{
//Expected
}
catch(...)
{
test(false);
}
//
// Test to create a timer with priorities too low
//
try
{
TimerPtr t = new Timer(THREAD_PRIORITY_IDLE - 10);
test(false);
}
catch(const ThreadSyscallException&)
{
//Expected
}
catch(...)
{
test(false);
}
#else
//
// Test to create a timer with a given priority
//
ThreadControl c;
try
{
for(int cont = 1; cont < 10; ++cont)
{
TimerPtr t = new Timer(cont);
}
}
catch(...)
{
test(false);
}
//
// Test to create a timer with priorities too high
//
for(int cont = 1; cont < 10; ++cont)
{
try
{
TimerPtr t = new Timer(300 * cont);
test(false);
}
catch(const ThreadSyscallException& e)
{
//Expected
//.........这里部分代码省略.........
开发者ID:2008hatake,项目名称:zeroc-ice,代码行数:101,代码来源:TimerPriority.cpp
注:本文中的TimerPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论