本文整理汇总了C++中TimerPtr类的典型用法代码示例。如果您正苦于以下问题:C++ TimerPtr类的具体用法?C++ TimerPtr怎么用?C++ TimerPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimerPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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();
}
示例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;
}
示例4: GetTimer
bool Time::ResumeTimer(const UInt& _uTimerID)
{
TimerPtr pTimer = GetTimer(_uTimerID);
bool bResult = (NULL != pTimer);
if (false != bResult)
{
bResult = pTimer->Resume();
}
return bResult;
}
示例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;
}
示例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{
}
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
示例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
}
示例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();
}
示例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;
}
示例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();
}
}
示例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+" ");
}
}
}
示例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);
}