git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@790 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
9c87b3b0c0
commit
adb6419766
60 changed files with 1017 additions and 1095 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* <thread.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
|
|
@ -42,79 +42,59 @@ static std :: vector <Thread *> threads;
|
|||
|
||||
unsigned num_act = 0;
|
||||
|
||||
Thread :: Thread ()
|
||||
{
|
||||
|
||||
Thread :: Thread () {
|
||||
|
||||
threads.push_back (this);
|
||||
act = false;
|
||||
}
|
||||
|
||||
Thread :: ~ Thread ()
|
||||
{
|
||||
Thread :: ~ Thread () {
|
||||
|
||||
/* Nothing ! */
|
||||
}
|
||||
|
||||
extern int getNodeRank ();
|
||||
|
||||
void Thread :: setActive ()
|
||||
{
|
||||
void Thread :: setActive () {
|
||||
|
||||
if (! act )
|
||||
{
|
||||
if (! act) {
|
||||
|
||||
act = true;
|
||||
num_act ++;
|
||||
// if (getNodeRank () == 1)
|
||||
// printf ("On passe a %d\n", num_act);
|
||||
}
|
||||
act = true;
|
||||
num_act ++;
|
||||
}
|
||||
}
|
||||
|
||||
void Thread :: setPassive ()
|
||||
{
|
||||
void Thread :: setPassive () {
|
||||
|
||||
if (act)
|
||||
{
|
||||
if (act) {
|
||||
|
||||
act = false;
|
||||
num_act --;
|
||||
// if (getNodeRank () == 1)
|
||||
// printf ("On passe a %d\n", num_act);
|
||||
|
||||
}
|
||||
act = false;
|
||||
num_act --;
|
||||
}
|
||||
}
|
||||
|
||||
bool atLeastOneActiveThread ()
|
||||
{
|
||||
bool atLeastOneActiveThread () {
|
||||
|
||||
return num_act;
|
||||
}
|
||||
|
||||
unsigned numberOfActiveThreads ()
|
||||
{
|
||||
static void * launch (void * __arg) {
|
||||
|
||||
return num_act;
|
||||
}
|
||||
|
||||
static void * launch (void * __arg)
|
||||
{
|
||||
|
||||
Thread * thr = (Thread *) __arg;
|
||||
Thread * thr = (Thread *) __arg;
|
||||
thr -> start ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads)
|
||||
{
|
||||
void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads) {
|
||||
|
||||
pthread_t * ll_thr = new pthread_t;
|
||||
__ll_threads.push_back (ll_thr);
|
||||
pthread_create (ll_thr, 0, launch, __hl_thread);
|
||||
pthread_create (ll_thr, 0, launch, __hl_thread);
|
||||
}
|
||||
|
||||
void joinThreads (std :: vector <pthread_t *> & __threads)
|
||||
{
|
||||
void joinThreads (std :: vector <pthread_t *> & __threads) {
|
||||
|
||||
for (unsigned i = 0; i < __threads.size (); i ++)
|
||||
pthread_join (* __threads [i], 0);
|
||||
for (unsigned i = 0; i < __threads.size (); i ++)
|
||||
pthread_join (* __threads [i], 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue