本文整理汇总了C++中TimerPtr::destroy方法的典型用法代码示例。如果您正苦于以下问题:C++ TimerPtr::destroy方法的具体用法?C++ TimerPtr::destroy怎么用?C++ TimerPtr::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimerPtr
的用法示例。
在下文中一共展示了TimerPtr::destroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: destroy
void Timer::destroy(int id)
{
TimerPtr timer = city::Timers::instance().find( id );
if( timer.isValid() )
timer->destroy();
}