Add the SMP module

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2714 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
quemy 2012-08-17 11:52:14 +00:00
commit 0890c67d31
43 changed files with 4030 additions and 41 deletions

View file

@ -0,0 +1,60 @@
#include <cassert>
#include <vector>
#include <atomic>
#include <smp>
#include "smpTestClass.h"
using namespace std;
using namespace paradiseo::smp;
void f(std::atomic<int> &x)
{
for(int i = 0; i < 100; i++) {
cout << x << endl;
x++;
}
}
void g(std::atomic<int> &x)
{
for(int i = 0; i < 100; i++)
x--;
}
void foo()
{
std::cout << "Foo" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
int main(void)
{
//---------------------------------------------------
std::atomic<int> nb(0);
Thread t1(&f,std::ref(nb));
Thread t2(&g,std::ref(nb));
t1.join();
t2.join();
assert(nb == 0); // Test atomic_barrier
//--------------------------------------------------
try
{
t1.start(foo);
t1.join();
}
catch(exception& e)
{
cout << "Exception: " << e.what() << '\n';
}
return 0;
}