本文整理汇总了C++中TimerList类的典型用法代码示例。如果您正苦于以下问题:C++ TimerList类的具体用法?C++ TimerList怎么用?C++ TimerList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimerList类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
//timer =new TimerList::MyTimer*[ntimers];
int i;
//_CrtMemState s1,s2, s3, s4, s5;
//_CrtMemCheckpoint( &s1 );
//for ( i = 0; i < ntimers; i++) timer[i]=t.setTimeout((i+1)*1,ding);
//for ( i = 0; i < ntimers; i++) t.deleteTimer(i);
//_CrtMemCheckpoint( &s2 );
//if ( _CrtMemDifference( &s3, &s1, &s2) ) _CrtMemDumpStatistics( &s3 );
//delete [] timer; timer=NULL;
thistimer=t.setInterval(100,ding);
t.setInterval(3000,dong);
while(1){
t.run();
}
return 0;
}
示例2: q
void TimersResponder::replyCreatedId(cTimer* timer, cxxtools::http::Request& request, cxxtools::http::Reply& reply, ostream& out)
{
QueryHandler q("/timers", request);
TimerList* timerList;
if ( q.isFormat(".html") ) {
reply.addHeader("Content-Type", "text/html; charset=utf-8");
timerList = (TimerList*)new HtmlTimerList(&out);
} else if ( q.isFormat(".xml") ) {
reply.addHeader("Content-Type", "text/xml; charset=utf-8");
timerList = (TimerList*)new XmlTimerList(&out);
} else {
reply.addHeader("Content-Type", "application/json; charset=utf-8");
timerList = (TimerList*)new JsonTimerList(&out);
}
timerList->init();
timerList->addTimer(timer);
timerList->setTotal(1);
timerList->finish();
delete timerList;
}
示例3: main
int main(int argc, char** argv) {
TimerList tm;
tm["total"] = new Timer("[Main] Total runtime for this proc");
tm["grid"] = new Timer("[Main] Grid generation");
tm["stencils"] = new Timer("[Main] Stencil generation");
tm["settings"] = new Timer("[Main] Load settings");
tm["decompose"] = new Timer("[Main] Decompose domain");
tm["consolidate"] = new Timer("[Main] Consolidate subdomain solutions");
tm["updates"] = new Timer("[Main] Broadcast solution updates");
tm["send"] = new Timer("[Main] Send subdomains to other processors (master only)");
tm["receive"] = new Timer("[Main] Receive subdomain from master (clients only)");
tm["timestep"] = new Timer("[Main] Advance One Timestep");
tm["tests"] = new Timer("[Main] Test stencil weights");
tm["weights"] = new Timer("[Main] Compute all stencils weights");
tm["oneWeight"] = new Timer("[Main] Compute single stencil weights");
tm["heat_init"] = new Timer("[Main] Initialize heat");
// grid should only be valid instance for MASTER
Grid* grid = NULL;
Domain* subdomain;
tm["total"]->start();
Communicator* comm_unit = new Communicator(argc, argv);
cout << " Got Rank: " << comm_unit->getRank() << endl;
cout << " Got Size: " << comm_unit->getSize() << endl;
tm["settings"]->start();
ProjectSettings* settings = new ProjectSettings(argc, argv, comm_unit->getRank());
int dim = settings->GetSettingAs<int>("DIMENSION", ProjectSettings::required);
//-----------------
fillGlobalProjectSettings(dim, settings);
//-----------------
int max_num_iters = settings->GetSettingAs<int>("MAX_NUM_ITERS", ProjectSettings::required);
double max_global_rel_error = settings->GetSettingAs<double>("MAX_GLOBAL_REL_ERROR", ProjectSettings::optional, "1e-1");
double max_local_rel_error = settings->GetSettingAs<double>("MAX_LOCAL_REL_ERROR", ProjectSettings::optional, "1e-1");
int use_gpu = settings->GetSettingAs<int>("USE_GPU", ProjectSettings::optional, "1");
int local_sol_dump_frequency = settings->GetSettingAs<int>("LOCAL_SOL_DUMP_FREQUENCY", ProjectSettings::optional, "100");
int global_sol_dump_frequency = settings->GetSettingAs<int>("GLOBAL_SOL_DUMP_FREQUENCY", ProjectSettings::optional, "200");
int prompt_to_continue = settings->GetSettingAs<int>("PROMPT_TO_CONTINUE", ProjectSettings::optional, "0");
int debug = settings->GetSettingAs<int>("DEBUG", ProjectSettings::optional, "0");
double start_time = settings->GetSettingAs<double>("START_TIME", ProjectSettings::optional, "0.0");
double end_time = settings->GetSettingAs<double>("END_TIME", ProjectSettings::optional, "1.0");
double dt = settings->GetSettingAs<double>("DT", ProjectSettings::optional, "1e-5");
int timescheme = settings->GetSettingAs<int>("TIME_SCHEME", ProjectSettings::optional, "1");
int weight_method = settings->GetSettingAs<int>("WEIGHT_METHOD", ProjectSettings::optional, "1");
int compute_eigenvalues = settings->GetSettingAs<int>("DERIVATIVE_EIGENVALUE_TEST", ProjectSettings::optional, "0");
int use_eigen_dt = settings->GetSettingAs<int>("USE_EIGEN_DT", ProjectSettings::optional, "1");
if (comm_unit->isMaster()) {
int ns_nx = settings->GetSettingAs<int>("NS_NB_X", ProjectSettings::optional, "10");
int ns_ny = settings->GetSettingAs<int>("NS_NB_Y", ProjectSettings::optional, "10");
int ns_nz = settings->GetSettingAs<int>("NS_NB_Z", ProjectSettings::optional, "10");
int stencil_size = settings->GetSettingAs<int>("STENCIL_SIZE", ProjectSettings::required);
tm["settings"]->stop();
grid = getGrid(dim);
grid->setMaxStencilSize(stencil_size);
Grid::GridLoadErrType err = grid->loadFromFile();
if (err == Grid::NO_GRID_FILES)
{
printf("************** Generating new Grid **************\n");
//grid->setSortBoundaryNodes(true);
// grid->setSortBoundaryNodes(true);
tm["grid"]->start();
grid->generate();
tm["grid"]->stop();
grid->writeToFile();
}
if ((err == Grid::NO_GRID_FILES) || (err == Grid::NO_STENCIL_FILES)) {
std::cout << "Generating stencils files\n";
tm["stencils"]->start();
grid->setNSHashDims(ns_nx, ns_ny, ns_nz);
// grid->generateStencils(Grid::ST_BRUTE_FORCE);
// DEFINTELY: exact
grid->generateStencils(Grid::ST_KDTREE);
// MIGHT BE: approximate
// grid->generateStencils(Grid::ST_HASH);
tm["stencils"]->stop();
grid->writeToFile();
tm.writeToFile("gridgen_timer_log");
}
int x_subdivisions = comm_unit->getSize(); // reduce this to impact y dimension as well
int y_subdivisions = (comm_unit->getSize() - x_subdivisions) + 1;
//.........这里部分代码省略.........
示例4: return
/**********************************************************************
*
* Method: isDone()
*
* Description: check for the software timer to finish.
*
* Notes:
*
* Returns: 1 on success, 0 if the timer is running.
*
**********************************************************************/
int
Timer::isDone()
{
#if 0
if (state != Active)
{
return (-1);
}
#endif
//
// Wait for the timer to expire.
//
if (state != Done)
return 0;
timerList.remove(this);
//
// Restart or idle the timer, depending on its type.
//
if (type == Periodic)
{
state = Active;
timerList.insert(this);
}
else
{
state = Idle;
}
return 1;
} /* isDone() */
示例5: return
/**********************************************************************
*
* Method: waitfor()
*
* Description: Wait for the software timer to finish.
*
* Notes:
*
* Returns: 0 on success, -1 if the timer is not running.
*
**********************************************************************/
int
Timer::waitfor()
{
if (state != Active)
{
return (-1);
}
//
// Wait for the timer to expire.
//
pMutex->take();
//
// Restart or idle the timer, depending on its type.
//
if (type == Periodic)
{
state = Active;
timerList.insert(this);
}
else
{
pMutex->release();
state = Idle;
}
return (0);
} /* waitfor() */
示例6: Interrupt
/**********************************************************************
*
* Method: Interrupt()
*
* Description: An interrupt handler for the timer hardware.
*
* Notes: This method is declared static, so that we cannot
* inadvertently modify any of the software timers.
*
* Returns: None defined.
*
**********************************************************************/
void
Timer::Interrupt()
{
//
// Decrement the active timer's count.
//
timerList.tick();
} /* Interrupt() */
示例7: CallTimers
void CallTimers()
{
Time now = Time::Now();
while (g_listTimers.GetCount() != 0) {
TRef<Timer> ptimer = g_listTimers.GetFront();
if (now < ptimer->m_when) {
break;
}
g_listTimers.PopFront();
if (ptimer->Trigger(now)) {
g_listTimers.InsertSorted(
new Timer(
ptimer->m_psink,
ptimer->m_delta,
Time::Now() + ptimer->m_delta
)
);
}
}
}
示例8: cancel
/**********************************************************************
*
* Method: cancel()
*
* Description: Stop a running timer.
*
* Notes:
*
* Returns: None defined.
*
**********************************************************************/
void
Timer::cancel(void)
{
//
// Remove the timer from the timer list.
//
if (state == Active)
{
timerList.remove(this);
}
//
// Reset the timer's state.
//
state = Idle;
} /* cancel() */
示例9: Interrupt
/**********************************************************************
*
* Method: Interrupt()
*
* Description: An interrupt handler for the timer hardware.
*
* Notes: This method is declared static, so that we cannot
* inadvertently modify any of the software timers.
*
* Returns: None defined.
*
**********************************************************************/
void interrupt
Timer::Interrupt()
{
//
// Decrement the active timer's count.
//
timerList.tick();
//
// Acknowledge the timer interrupt.
//
gProcessor.pPCB->intControl.eoi = EOI_NONSPECIFIC;
//
// Clear the Maximum Count bit (to start the next cycle).
//
gProcessor.pPCB->timer[2].control &= ~TIMER_MAXCOUNT;
} /* Interrupt() */
示例10: RemoveSink
void Window::RemoveSink(IEventSink* psink)
{
g_listTimers.Remove(new Timer(psink, 0, 0));
}
示例11: AddSink
void Window::AddSink(IEventSink* psink, float delta)
{
g_listTimers.InsertSorted(new Timer(psink, delta, Time::Now() + delta));
}