Changeset 3718 in Sophya for trunk/SophyaLib/SysTools/zthread.cc


Ignore:
Timestamp:
Dec 28, 2009, 10:05:51 PM (16 years ago)
Author:
ansari
Message:

1/ Corrections et modifications mineures ds ZThread, et ajout des classes

ParallelTaskInterface, ParalExThread, ParallelExecutor pour l'execution

de fonctions en parallele dans des threads, Reza 28/12/2009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/zthread.cc

    r3619 r3718  
    6363{
    6464  ZThread * thr = (ZThread *)xthr;
    65   if(thr->_status == 1) thr->_status = 2;
     65  if(thr->_status == 2) thr->_status = 3;
    6666  return;
    6767}
     
    7676/* ------ Classe ZThread  -------  */
    7777/*!
    78   Constructor, with optional specification of the thread stack size.
     78  Constructor, with optional specification of the thread stack size in bytes.
     79  if not specified or zero, defaut system stack size is used.
    7980*/
    8081ZThread::ZThread(size_t stacksize)
    8182{
    8283  _status = 0;
     84  _fgstarted = false;
    8385  _ssize = 0;
    8486  _act = NULL;
     
    9395
    9496/*!
    95   Method which starts the thread.
     97  Method which starts the thread.
     98  The thread object is created by a call to pthread_create() in this method.
    9699*/
    97100void ZThread::start()
    98101{
    99   if ( IfStarted() ) throw ZThreadExc("ZThread::Start() - Already started thread !");
     102  if ( _fgstarted ) throw ZThreadExc("ZThread::Start() - Already started thread !");
     103  _fgstarted = true;
     104  _status = 1;
    100105  int rc;
    101106  pthread_attr_t tha;
     
    154159{
    155160  if (_act)  _act(_usp);
    156   setRC(0);     
     161  exit(0);     
    157162  return;
    158163}
     
    165170void ZThread::run_p()
    166171{
    167   _status = 1;
     172  _status = 2;
    168173  pthread_cleanup_push(zthr_cleanup, (void *)this);
    169174  run();
    170   _status = 2;
     175  _status = 3;
    171176  pthread_exit(&(_rc));
    172177  pthread_cleanup_pop(0);
     
    212217
    213218/*!
    214   Constructor: Creates a associated pair of POSIX \c pthread_mutex_t
     219  Constructor: Creates an associated pair of POSIX \c pthread_mutex_t
    215220  and \c pthread_cond_t objects
    216221  \param : if fgd == true , the destructor call pthread_mutex_destroy/pthread_cond_destroy
Note: See TracChangeset for help on using the changeset viewer.