mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
30 lines
690 B
C++
30 lines
690 B
C++
#include <LatAnalyze/Core/ThreadPool.hpp>
|
|
|
|
using namespace std;
|
|
using namespace Latan;
|
|
|
|
int main(void)
|
|
{
|
|
ThreadPool pool;
|
|
|
|
cout << "Using " << pool.getThreadNum() << " threads" << endl;
|
|
for (unsigned int i = 1; i <= 20; ++i)
|
|
{
|
|
pool.addJob([i, &pool](void)
|
|
{
|
|
pool.critical([i](void)
|
|
{
|
|
cout << "job " << i << " wait for " << i*100 << " ms" << endl;
|
|
});
|
|
this_thread::sleep_for(chrono::milliseconds(i*100));
|
|
pool.critical([i](void)
|
|
{
|
|
cout << "job " << i << " done" << endl;
|
|
});
|
|
});
|
|
}
|
|
pool.terminate();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|