本文整理汇总了C++中MyTimer::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ MyTimer::Count方法的具体用法?C++ MyTimer::Count怎么用?C++ MyTimer::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyTimer
的用法示例。
在下文中一共展示了MyTimer::Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test
void SuiteTimerBasic::Test()
{
MyTimer a(iEnv);
TUint i=0;
for( ; i < 100; i++ ) {
a.FireIn(300);
Thread::Sleep(iEnv.Random(30, 10));
Print(".");
}
#if 0
a.Wait();
TUint count0 = a.Count();
Thread::Sleep(3000);
TUint count1 = a.Count();
TEST(count0 == count1);
for( i=0; i < 100; i++ ) {
a.FireIn(300);
TUint j = iEnv.Random(3500, 2500);
TUint k=0;
for( ; k < j; k++) {
Print(".");
}
}
a.Wait();
Thread::Sleep(3000);
MyTimer b(iEnv);
Print("\nWait for 5 seconds\n");
a.FireIn(5000);
a.Wait();
Print("Wait finished\n");
Print("Wait for 3 seconds then a further 2 seconds\n");
a.FireIn(5000);
b.FireIn(3000);
b.Wait();
Print("Wait finished 1\n");
a.Wait();
Print("Wait finished 2\n");
for (TUint j = 1; j < 21; j++) {
Print("Wait for 1 second then a further %d millisecond\n", j);
a.FireIn(1000);
b.FireIn(1000 + j);
a.Wait();
Print("Wait finished 1\n");
b.Wait();
Print("Wait finished 2\n");
}
Print("Wait for 0 seconds\n");
a.FireIn(0);
a.Wait();
Print("Wait finished\n");
Print("Cancel a timer\n");
MyTimer c(iEnv);
a.FireIn(1000);
c.FireIn(2000);
b.FireIn(3000);
a.Wait();
Print("Wait finished 1\n");
TEST(c.Count() == 0);
c.Cancel();
b.Wait();
Print("Wait finished 2\n");
TEST(c.Count() == 0);
Print("Delete a timer\n");
MyTimer* d = new MyTimer(iEnv);
a.FireIn(1000);
d->FireIn(2000);
b.FireIn(3000);
a.Wait();
Print("Wait finished 1\n");
TEST(d->Count() == 0);
delete d;
b.Wait();
Print("Wait finished 2\n");
Print("Change a timer\n");
// Replaced 'a' with a new timer 'a2', as this code
// assumes the MyTimer sema count is 0. Not guaranteed though :(
MyTimer a2(iEnv);
MyTimer e(iEnv);
a2.FireIn(1000);
//.........这里部分代码省略.........
示例2: Test
void SuiteTimerBasic::Test()
{
MyTimer a;
TUint i=0;
for( ; i < 1000; i++ ) {
a.FireIn(300);
Thread::Current()->Sleep(Random(30, 10));
Print(".");
}
a.Wait();
TUint count0 = a.Count();
Thread::Current()->Sleep(3000);
TUint count1 = a.Count();
TEST(count0 == count1);
for( i=0; i < 100; i++ ) {
a.FireIn(300);
TUint j = Random(3500, 2500);
TUint k=0;
for( ; k < j; k++) {
Print(".");
}
}
a.Wait();
Thread::Current()->Sleep(3000);
MyTimer b;
Print("\nWait for 5 seconds\n");
a.FireIn(5000);
a.Wait();
Print("Wait finished\n");
Print("Wait for 3 seconds then a further 2 seconds\n");
a.FireIn(5000);
b.FireIn(3000);
b.Wait();
Print("Wait finished 1\n");
a.Wait();
Print("Wait finished 2\n");
for (TUint i = 1; i < 21; i++) {
Print("Wait for 1 second then a further %d millisecond\n", i);
a.FireIn(1000);
b.FireIn(1000 + i);
a.Wait();
Print("Wait finished 1\n");
b.Wait();
Print("Wait finished 2\n");
}
Print("Wait for 0 seconds\n");
a.FireIn(0);
a.Wait();
Print("Wait finished\n");
Print("Cancel a timer\n");
MyTimer c;
a.FireIn(1000);
c.FireIn(2000);
b.FireIn(3000);
a.Wait();
Print("Wait finished 1\n");
TEST(c.Count() == 0);
c.Cancel();
b.Wait();
Print("Wait finished 2\n");
TEST(c.Count() == 0);
Print("Delete a timer\n");
MyTimer* d = new MyTimer();
a.FireIn(1000);
d->FireIn(2000);
b.FireIn(3000);
a.Wait();
Print("Wait finished 1\n");
TEST(d->Count() == 0);
delete d;
b.Wait();
Print("Wait finished 2\n");
Print("Change a timer\n");
MyTimer e;
a.FireIn(1000);
e.FireIn(2000);
b.FireIn(3000);
a.Wait();
//.........这里部分代码省略.........