Changeset 3718 in Sophya for trunk


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

Location:
trunk/SophyaLib/SysTools
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SysTools/Makefile

    r3615 r3718  
    44 
    55clean:
    6          rm -f $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)zthread.o $(SOPHYAOBJP)timing.o
     6         rm -f $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)parlex.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)zthread.o $(SOPHYAOBJP)timing.o
    77        rm -f $(SOPHYALIBP)libSysTools.a
    88 
    9 $(SOPHYALIBP)libSysTools.a : $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)timing.o $(SOPHYAOBJP)zthread.o
     9$(SOPHYALIBP)libSysTools.a : $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)parlex.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)timing.o $(SOPHYAOBJP)zthread.o
    1010        $(AR) $(ARFLAGS) $@ $?
    1111        touch $(SOPHYAINCP)/SophyaConfInfo/libsophya.objlist
    1212 
    13 $(SOPHYAOBJP)cexpre.o: cexpre.cc $(SOPHYAINCP)sopnamsp.h \
    14   cexpre.h $(SOPHYAINCP)machdefs.h \
     13$(SOPHYAOBJP)cexpre.o: cexpre.cc $(SOPHYAINCP)sopnamsp.h cexpre.h \
     14  $(SOPHYAINCP)machdefs.h \
     15  $(SOPHYAINCP)osx_values.h \
    1516  $(SOPHYAINCP)pexceptions.h \
    1617  $(SOPHYAINCP)machdefs.h \
    1718  $(SOPHYAINCP)srandgen.h \
     19  $(SOPHYAINCP)machdefs.h \
    1820  $(SOPHYAINCP)randinterf.h \
    19   $(SOPHYAINCP)anydataobj.h
     21  $(SOPHYAINCP)machdefs.h \
     22  $(SOPHYAINCP)anydataobj.h \
     23  $(SOPHYAINCP)machdefs.h
    2024        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  cexpre.cc
    2125 
    2226$(SOPHYAOBJP)commander.o: commander.cc $(SOPHYAINCP)sopnamsp.h \
    23   commander.h $(SOPHYAINCP)machdefs.h pdlmgr.h \
    24   $(SOPHYAINCP)dvlist.h \
    25   $(SOPHYAINCP)objfio.h \
     27  commander.h $(SOPHYAINCP)machdefs.h \
     28  $(SOPHYAINCP)osx_values.h pdlmgr.h \
     29  $(SOPHYAINCP)dvlist.h $(SOPHYAINCP)objfio.h \
    2630  $(SOPHYAINCP)machdefs.h \
    2731  $(SOPHYAINCP)anydataobj.h \
     32  $(SOPHYAINCP)machdefs.h \
    2833  $(SOPHYAINCP)ppersist.h \
     34  $(SOPHYAINCP)machdefs.h \
    2935  $(SOPHYAINCP)pexceptions.h \
    30   $(SOPHYAINCP)gnumd5.h \
     36  $(SOPHYAINCP)machdefs.h $(SOPHYAINCP)gnumd5.h \
    3137  $(SOPHYAINCP)ppfbinstream.h \
     38  $(SOPHYAINCP)machdefs.h \
    3239  $(SOPHYAINCP)rawstream.h \
     40  $(SOPHYAINCP)machdefs.h \
    3341  $(SOPHYAINCP)ppfnametag.h \
    34   $(SOPHYAINCP)mutyv.h \
    35   $(SOPHYAINCP)timestamp.h ctimer.h \
    36   $(SOPHYAINCP)strutil.h \
    37   $(SOPHYAINCP)strutilxx.h cexpre.h \
    38   $(SOPHYAINCP)pexceptions.h rpneval.h \
     42  $(SOPHYAINCP)ppersist.h $(SOPHYAINCP)mutyv.h \
     43  $(SOPHYAINCP)machdefs.h \
     44  $(SOPHYAINCP)timestamp.h \
     45  $(SOPHYAINCP)machdefs.h $(SOPHYAINCP)objfio.h \
     46  ctimer.h $(SOPHYAINCP)strutil.h \
     47  $(SOPHYAINCP)strutilxx.h \
     48  $(SOPHYAINCP)machdefs.h cexpre.h rpneval.h \
    3949  $(SOPHYAINCP)srandgen.h \
    40   $(SOPHYAINCP)randinterf.h zthread.h
     50  $(SOPHYAINCP)machdefs.h \
     51  $(SOPHYAINCP)randinterf.h \
     52  $(SOPHYAINCP)machdefs.h \
     53  $(SOPHYAINCP)anydataobj.h zthread.h
    4154        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  commander.cc
    4255 
    4356$(SOPHYAOBJP)ctimer.o: ctimer.cc $(SOPHYAINCP)machdefs.h \
    44   $(SOPHYAINCP)sopnamsp.h ctimer.h
     57  $(SOPHYAINCP)osx_values.h ctimer.h
    4558        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ctimer.cc
    4659 
    4760$(SOPHYAOBJP)cxxcmplnk.o: cxxcmplnk.cc $(SOPHYAINCP)sopnamsp.h \
    4861  cxxcmplnk.h $(SOPHYAINCP)machdefs.h \
     62  $(SOPHYAINCP)osx_values.h \
    4963  $(SOPHYAINCP)sspvflags.h
    5064        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  cxxcmplnk.cc
    5165 
     66$(SOPHYAOBJP)parlex.o: parlex.cc parlex.h zthread.h \
     67  $(SOPHYAINCP)machdefs.h \
     68  $(SOPHYAINCP)osx_values.h \
     69  $(SOPHYAINCP)pexceptions.h \
     70  $(SOPHYAINCP)machdefs.h
     71        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  parlex.cc
     72 
    5273$(SOPHYAOBJP)pdlmgr.o: pdlmgr.cc $(SOPHYAINCP)machdefs.h \
     74  $(SOPHYAINCP)osx_values.h \
    5375  $(SOPHYAINCP)sopnamsp.h pdlmgr.h
    5476        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pdlmgr.cc
    5577 
    5678$(SOPHYAOBJP)periodic.o: periodic.cc $(SOPHYAINCP)sopnamsp.h \
    57   $(SOPHYAINCP)machdefs.h periodic.h
     79  $(SOPHYAINCP)machdefs.h \
     80  $(SOPHYAINCP)osx_values.h periodic.h
    5881        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  periodic.cc
    5982 
    60 $(SOPHYAOBJP)psighand.o: psighand.cc $(SOPHYAINCP)sopnamsp.h \
    61   psighand.h $(SOPHYAINCP)machdefs.h \
     83$(SOPHYAOBJP)psighand.o: psighand.cc $(SOPHYAINCP)sopnamsp.h psighand.h \
     84  $(SOPHYAINCP)machdefs.h \
     85  $(SOPHYAINCP)osx_values.h \
    6286  $(SOPHYAINCP)pexceptions.h \
    6387  $(SOPHYAINCP)machdefs.h
    6488        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  psighand.cc
    6589 
    66 $(SOPHYAOBJP)resusage.o: resusage.cc $(SOPHYAINCP)sopnamsp.h \
    67   resusage.h $(SOPHYAINCP)machdefs.h
     90$(SOPHYAOBJP)resusage.o: resusage.cc $(SOPHYAINCP)sopnamsp.h resusage.h \
     91  $(SOPHYAINCP)machdefs.h \
     92  $(SOPHYAINCP)osx_values.h
    6893        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  resusage.cc
    6994 
    70 $(SOPHYAOBJP)rpneval.o: rpneval.cc $(SOPHYAINCP)sopnamsp.h \
    71   rpneval.h $(SOPHYAINCP)machdefs.h \
     95$(SOPHYAOBJP)rpneval.o: rpneval.cc $(SOPHYAINCP)sopnamsp.h rpneval.h \
     96  $(SOPHYAINCP)machdefs.h \
     97  $(SOPHYAINCP)osx_values.h \
    7298  $(SOPHYAINCP)pexceptions.h \
    7399  $(SOPHYAINCP)machdefs.h \
    74100  $(SOPHYAINCP)strutilxx.h \
     101  $(SOPHYAINCP)machdefs.h \
    75102  $(SOPHYAINCP)srandgen.h \
     103  $(SOPHYAINCP)machdefs.h \
    76104  $(SOPHYAINCP)randinterf.h \
    77   $(SOPHYAINCP)anydataobj.h
     105  $(SOPHYAINCP)machdefs.h \
     106  $(SOPHYAINCP)anydataobj.h \
     107  $(SOPHYAINCP)machdefs.h
    78108        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  rpneval.cc
    79109 
    80 $(SOPHYAOBJP)zthread.o: zthread.cc $(SOPHYAINCP)sopnamsp.h \
    81   zthread.h $(SOPHYAINCP)machdefs.h \
     110$(SOPHYAOBJP)zthread.o: zthread.cc $(SOPHYAINCP)sopnamsp.h zthread.h \
     111  $(SOPHYAINCP)machdefs.h \
     112  $(SOPHYAINCP)osx_values.h \
    82113  $(SOPHYAINCP)pexceptions.h \
    83114  $(SOPHYAINCP)machdefs.h
  • trunk/SophyaLib/SysTools/objlist.list

    r2510 r3718  
    33ctimer.o
    44cxxcmplnk.o
     5parlex.o
    56pdlmgr.o
    67periodic.o
  • trunk/SophyaLib/SysTools/smakefile

    r3615 r3718  
    44 
    55clean:
    6          rm -f $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)zthread.o $(SOPHYAOBJP)timing.o
     6         rm -f $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)parlex.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)zthread.o $(SOPHYAOBJP)timing.o
    77        rm -f $(SOPHYALIBP)libSysTools.a
    88 
    9 $(SOPHYALIBP)libSysTools.a : $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)timing.o $(SOPHYAOBJP)zthread.o
     9$(SOPHYALIBP)libSysTools.a : $(SOPHYAOBJP)cexpre.o $(SOPHYAOBJP)commander.o $(SOPHYAOBJP)ctimer.o $(SOPHYAOBJP)cxxcmplnk.o $(SOPHYAOBJP)parlex.o $(SOPHYAOBJP)pdlmgr.o $(SOPHYAOBJP)periodic.o $(SOPHYAOBJP)psighand.o $(SOPHYAOBJP)resusage.o $(SOPHYAOBJP)rpneval.o $(SOPHYAOBJP)timing.o $(SOPHYAOBJP)zthread.o
    1010        $(AR) $(ARFLAGS) $@ $?
    1111        touch $(SOPHYAINCP)/SophyaConfInfo/libsophya.objlist
    1212 
    13 $(SOPHYAOBJP)cexpre.o: cexpre.cc $(SOPHYAINCP)sopnamsp.h \
    14   cexpre.h $(SOPHYAINCP)machdefs.h \
     13$(SOPHYAOBJP)cexpre.o: cexpre.cc $(SOPHYAINCP)sopnamsp.h cexpre.h \
     14  $(SOPHYAINCP)machdefs.h \
     15  $(SOPHYAINCP)osx_values.h \
    1516  $(SOPHYAINCP)pexceptions.h \
    1617  $(SOPHYAINCP)machdefs.h \
    1718  $(SOPHYAINCP)srandgen.h \
     19  $(SOPHYAINCP)machdefs.h \
    1820  $(SOPHYAINCP)randinterf.h \
    19   $(SOPHYAINCP)anydataobj.h
     21  $(SOPHYAINCP)machdefs.h \
     22  $(SOPHYAINCP)anydataobj.h \
     23  $(SOPHYAINCP)machdefs.h
    2024        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  cexpre.cc
    2125 
    2226$(SOPHYAOBJP)commander.o: commander.cc $(SOPHYAINCP)sopnamsp.h \
    23   commander.h $(SOPHYAINCP)machdefs.h pdlmgr.h \
    24   $(SOPHYAINCP)dvlist.h \
    25   $(SOPHYAINCP)objfio.h \
     27  commander.h $(SOPHYAINCP)machdefs.h \
     28  $(SOPHYAINCP)osx_values.h pdlmgr.h \
     29  $(SOPHYAINCP)dvlist.h $(SOPHYAINCP)objfio.h \
    2630  $(SOPHYAINCP)machdefs.h \
    2731  $(SOPHYAINCP)anydataobj.h \
     32  $(SOPHYAINCP)machdefs.h \
    2833  $(SOPHYAINCP)ppersist.h \
     34  $(SOPHYAINCP)machdefs.h \
    2935  $(SOPHYAINCP)pexceptions.h \
    30   $(SOPHYAINCP)gnumd5.h \
     36  $(SOPHYAINCP)machdefs.h $(SOPHYAINCP)gnumd5.h \
    3137  $(SOPHYAINCP)ppfbinstream.h \
     38  $(SOPHYAINCP)machdefs.h \
    3239  $(SOPHYAINCP)rawstream.h \
     40  $(SOPHYAINCP)machdefs.h \
    3341  $(SOPHYAINCP)ppfnametag.h \
    34   $(SOPHYAINCP)mutyv.h \
    35   $(SOPHYAINCP)timestamp.h ctimer.h \
    36   $(SOPHYAINCP)strutil.h \
    37   $(SOPHYAINCP)strutilxx.h cexpre.h \
    38   $(SOPHYAINCP)pexceptions.h rpneval.h \
     42  $(SOPHYAINCP)ppersist.h $(SOPHYAINCP)mutyv.h \
     43  $(SOPHYAINCP)machdefs.h \
     44  $(SOPHYAINCP)timestamp.h \
     45  $(SOPHYAINCP)machdefs.h $(SOPHYAINCP)objfio.h \
     46  ctimer.h $(SOPHYAINCP)strutil.h \
     47  $(SOPHYAINCP)strutilxx.h \
     48  $(SOPHYAINCP)machdefs.h cexpre.h rpneval.h \
    3949  $(SOPHYAINCP)srandgen.h \
    40   $(SOPHYAINCP)randinterf.h zthread.h
     50  $(SOPHYAINCP)machdefs.h \
     51  $(SOPHYAINCP)randinterf.h \
     52  $(SOPHYAINCP)machdefs.h \
     53  $(SOPHYAINCP)anydataobj.h zthread.h
    4154        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  commander.cc
    4255 
    4356$(SOPHYAOBJP)ctimer.o: ctimer.cc $(SOPHYAINCP)machdefs.h \
    44   $(SOPHYAINCP)sopnamsp.h ctimer.h
     57  $(SOPHYAINCP)osx_values.h ctimer.h
    4558        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  ctimer.cc
    4659 
    4760$(SOPHYAOBJP)cxxcmplnk.o: cxxcmplnk.cc $(SOPHYAINCP)sopnamsp.h \
    4861  cxxcmplnk.h $(SOPHYAINCP)machdefs.h \
     62  $(SOPHYAINCP)osx_values.h \
    4963  $(SOPHYAINCP)sspvflags.h
    5064        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  cxxcmplnk.cc
    5165 
     66$(SOPHYAOBJP)parlex.o: parlex.cc parlex.h zthread.h \
     67  $(SOPHYAINCP)machdefs.h \
     68  $(SOPHYAINCP)osx_values.h \
     69  $(SOPHYAINCP)pexceptions.h \
     70  $(SOPHYAINCP)machdefs.h
     71        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  parlex.cc
     72 
    5273$(SOPHYAOBJP)pdlmgr.o: pdlmgr.cc $(SOPHYAINCP)machdefs.h \
     74  $(SOPHYAINCP)osx_values.h \
    5375  $(SOPHYAINCP)sopnamsp.h pdlmgr.h
    5476        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  pdlmgr.cc
    5577 
    5678$(SOPHYAOBJP)periodic.o: periodic.cc $(SOPHYAINCP)sopnamsp.h \
    57   $(SOPHYAINCP)machdefs.h periodic.h
     79  $(SOPHYAINCP)machdefs.h \
     80  $(SOPHYAINCP)osx_values.h periodic.h
    5881        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  periodic.cc
    5982 
    60 $(SOPHYAOBJP)psighand.o: psighand.cc $(SOPHYAINCP)sopnamsp.h \
    61   psighand.h $(SOPHYAINCP)machdefs.h \
     83$(SOPHYAOBJP)psighand.o: psighand.cc $(SOPHYAINCP)sopnamsp.h psighand.h \
     84  $(SOPHYAINCP)machdefs.h \
     85  $(SOPHYAINCP)osx_values.h \
    6286  $(SOPHYAINCP)pexceptions.h \
    6387  $(SOPHYAINCP)machdefs.h
    6488        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  psighand.cc
    6589 
    66 $(SOPHYAOBJP)resusage.o: resusage.cc $(SOPHYAINCP)sopnamsp.h \
    67   resusage.h $(SOPHYAINCP)machdefs.h
     90$(SOPHYAOBJP)resusage.o: resusage.cc $(SOPHYAINCP)sopnamsp.h resusage.h \
     91  $(SOPHYAINCP)machdefs.h \
     92  $(SOPHYAINCP)osx_values.h
    6893        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  resusage.cc
    6994 
    70 $(SOPHYAOBJP)rpneval.o: rpneval.cc $(SOPHYAINCP)sopnamsp.h \
    71   rpneval.h $(SOPHYAINCP)machdefs.h \
     95$(SOPHYAOBJP)rpneval.o: rpneval.cc $(SOPHYAINCP)sopnamsp.h rpneval.h \
     96  $(SOPHYAINCP)machdefs.h \
     97  $(SOPHYAINCP)osx_values.h \
    7298  $(SOPHYAINCP)pexceptions.h \
    7399  $(SOPHYAINCP)machdefs.h \
    74100  $(SOPHYAINCP)strutilxx.h \
     101  $(SOPHYAINCP)machdefs.h \
    75102  $(SOPHYAINCP)srandgen.h \
     103  $(SOPHYAINCP)machdefs.h \
    76104  $(SOPHYAINCP)randinterf.h \
    77   $(SOPHYAINCP)anydataobj.h
     105  $(SOPHYAINCP)machdefs.h \
     106  $(SOPHYAINCP)anydataobj.h \
     107  $(SOPHYAINCP)machdefs.h
    78108        $(CXXCOMPILE) $(CXXTEMPFLG) -o $@  rpneval.cc
    79109 
    80 $(SOPHYAOBJP)zthread.o: zthread.cc $(SOPHYAINCP)sopnamsp.h \
    81   zthread.h $(SOPHYAINCP)machdefs.h \
     110$(SOPHYAOBJP)zthread.o: zthread.cc $(SOPHYAINCP)sopnamsp.h zthread.h \
     111  $(SOPHYAINCP)machdefs.h \
     112  $(SOPHYAINCP)osx_values.h \
    82113  $(SOPHYAINCP)pexceptions.h \
    83114  $(SOPHYAINCP)machdefs.h
  • 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
  • trunk/SophyaLib/SysTools/zthread.h

    r3586 r3718  
    3131  explicit      ZThread(size_t stacksize=0);
    3232  virtual       ~ZThread();
     33  //! Change the thread stack-size, specified in bytes. Can only be called before the thread is started
     34  inline void   setStackSize(size_t ssz) { _ssize=ssz; }
     35  //! Change the thread stack-size, specified in kilobytes. Can only be called before the thread is started
     36  inline void   setStackSizekb(size_t sszk) { _ssize=sszk*1024; }
     37
    3338  void          start();
    3439  void          cancel();
    3540  void          kill(int sig);
     41  void          join();
    3642
    37   void          join();
    3843  virtual void  run();
    3944
    4045  //! Returns true if the thread has been created / started
    41   bool IfStarted() { return ((_status > 0) ? true : false); }
     46  bool IfStarted() { return (((_fgstarted)||(_status>0)) ? true : false); }
    4247  //! Returns true if the thread is running
    43   bool IfRunning() { return ((_status == 1) ? true : false); }
     48  bool IfRunning() { return ((_status == 2) ? true : false); }
    4449  //! Returns true if the thread has ended normally
    45   bool IfEnded() { return ((_status == 2) ? true : false); }
     50  bool IfEnded() { return ((_status == 3) ? true : false); }
    4651  //! Returns true if the thread has been stopped (killed/canceled)
    47   bool IfStopped() { return ((_status == 3) ? true : false); }
     52  bool IfStopped() { return ((_status == 5) ? true : false); }
    4853
    4954  //! Sets the return code for the thread object
     
    7782  // PTHREAD_CANCEL_DEFERRED  ou  PTHREAD_CANCEL_ASYNCHRONOUS
    7883
     84  /*!
     85    \brief This method is only for internal use by zthread.cc and should not be called by users
     86  */
    7987  virtual void  run_p();
    8088
     
    8391  size_t _ssize;
    8492  int _rc;
    85   int _status; // 0 : not started, 1: running, 2: ended, 3:stopped
    86 
     93  int _status; // 0 : not started, 1 : started, 2: running, 3: ended, 5:stopped
     94  bool _fgstarted;   // false -> true par appel a start()
    8795  ZThreadAction _act;
    8896  void * _usp;
Note: See TracChangeset for help on using the changeset viewer.