|
reSIProcate/rutil
9694
|
#include "rutil/ThreadIf.hxx"#include "rutil/Timer.hxx"#include <unistd.h>#include <iostream>#include <vector>#include <cassert>
Go to the source code of this file.
Classes | |
| class | Every4 |
| class | Old2 |
| class | ShutdownSelf |
| class | DerivedShutsDown |
Functions | |
| int | main () |
| int main | ( | void | ) |
Definition at line 77 of file testThreadIf.cxx.
References resip::Timer::getTimeMs(), resip::ThreadIf::join(), resip::ThreadIf::run(), and resip::ThreadIf::shutdown().
{
{
DerivedShutsDown d;
}
{
vector<DerivedShutsDown*> threads;
int numThreads = 20;
for (int i=0; i < numThreads; i++)
{
threads.push_back(new DerivedShutsDown);
threads.back()->run();
}
sleep(1);
for (int i=0; i < numThreads; i++)
{
delete threads[i];
}
cerr << "finished many-thread test" << endl;
}
{
DerivedShutsDown d;
d.run();
usleep(10000);
}
{
ShutdownSelf* s= new ShutdownSelf();
s->run();
usleep(10000);
s->shutdown();
delete s;
}
{
Every4 e;
e.run();
sleep(5);
UInt64 t = Timer::getTimeMs();
cerr << "Stopping thread at: " << Timer::getTimeMs() << endl;
e.shutdown();
e.join();
UInt64 j = Timer::getTimeMs();
cerr << j - t << endl;
assert(j - t < 20);
}
//this should not cause problems(signal is being called on a condition with
//no waiting threads).
{
Old2 o;
o.run();
sleep(3);
o.shutdown();
o.join();
}
cerr << "OK" << endl;
return 0;
}

1.7.5.1