Index: trunk/SophyaLib/SysTools/parlex.cc
===================================================================
--- trunk/SophyaLib/SysTools/parlex.cc	(revision 3814)
+++ trunk/SophyaLib/SysTools/parlex.cc	(revision 3855)
@@ -11,7 +11,39 @@
 
 /*!
+  \class ParallelTaskInterface
+  \ingroup SysTools
+  \brief Interface definition for parallel task object. 
+
+  The pure virtual method execute() should be redefined by the classes
+  inheriting from ParallelTaskInterface
+*/  
+ParallelTaskInterface::ParallelTaskInterface()
+{
+  setNbParallelThreads(0);
+}
+ParallelTaskInterface::~ParallelTaskInterface()
+{
+}
+/*!
+  \brief Define the number of parallel threads running to perform the task 
+
+  This method is called by ParallelExecutor object. If subclasses overwrite this method, 
+  base class method should be called to set the value of nbparallel_ attribute.
+*/
+void ParallelTaskInterface::setNbParallelThreads(int nbparthr)
+{
+  nbparallel_=nbparthr;
+}
+
+/*!
   \class ParallelTaskFunction 
   \ingroup SysTools
   \brief ParallelTaskInterface implementation for functions 
+
+  The function which are executed by the ParallelTaskFunction execute() method should
+  conform to the prototype:  int func(int tid, int nparthr)
+
+  tid (counting from zero) is the thread rank, and nparthr the number of parallel threads 
+  executing in the context
 */  
 //! Constructor with the specification of the function to be executed 
@@ -22,5 +54,5 @@
 int ParallelTaskFunction::execute(int tid)
 {
-  return parfunc_(tid);
+  return parfunc_(tid, getNbParallelThreads());
 }
 
@@ -184,4 +216,5 @@
     vrc_[i] = 0;
   }
+  ptask.setNbParallelThreads( nthr );
 }
 
@@ -195,6 +228,8 @@
 {
   if (vptask.size()<1) throw ParmError("ParallelExecutor(vector<ptask>/Error vptask.size()<1"); 
+  int nthr= (int)nThreads();
   for(size_t i=0; i<vpext_.size(); i++) {
     vpext_[i] = new ParalExThread( (*vptask[i]), i);
+    vptask[i]->setNbParallelThreads(nthr);
     vrc_[i] = 0;
   }
@@ -219,4 +254,5 @@
   for(size_t i=0; i<vpext_.size(); i++)
     vpext_[i]->setParallelTask(ptask);
+  ptask.setNbParallelThreads( (int)nThreads() );
   return;
 }
@@ -229,6 +265,9 @@
   if (vptask.size()!=vpext_.size()) 
     throw SzMismatchError("ParallelExecutor::SetParallelTask(vector<ptask>) - vptask.size()!=vpext.size()");
-  for(size_t i=0; i<vpext_.size(); i++)
+  int nthr= (int)nThreads();
+  for(size_t i=0; i<vpext_.size(); i++) {
     vpext_[i]->setParallelTask(*vptask[i]);
+    vptask[i]->setNbParallelThreads(nthr);
+  }
   return;
 }
Index: trunk/SophyaLib/SysTools/parlex.h
===================================================================
--- trunk/SophyaLib/SysTools/parlex.h	(revision 3814)
+++ trunk/SophyaLib/SysTools/parlex.h	(revision 3855)
@@ -5,5 +5,5 @@
 
 // Classes pour execution de taches paralleles en utilisant les threads
-//    R. Ansari       UPS+LAL IN2P3/CNRS  2005
+//    R. Ansari       UPS+LAL IN2P3/CNRS  2009-2010
 
 #include "zthread.h"
@@ -17,26 +17,25 @@
 //  s'executer en parallele
 //--------------------------------------------------------------------
-/*!
-  \class ParallelTaskInterface
-  \ingroup SysTools
-  \brief Interface definition for parallel task object. 
-
-  The pure virtual method execute() should be redefined by the classes
-  inheriting from ParallelTaskInterface
-*/  
 class ParallelTaskInterface {
 public:
-  explicit       ParallelTaskInterface()  { }
-  virtual        ~ParallelTaskInterface() { }
+  explicit       ParallelTaskInterface();
+  virtual        ~ParallelTaskInterface(); 
   /*! This method should perform the actual computation. The parameter tid 
     is used by the ParallelExecutor class to identify the thread calling the method
   */
   virtual int    execute(int tid) = 0; 
+  //! Define the number of parallel threads running to perform the task (set by ParallelExecutor object)
+  virtual void   setNbParallelThreads(int nbparthr);
+  //! Return the number of parallel threads running to perform the task
+  inline  int    getNbParallelThreads() { return nbparallel_; }
+protected:
+  int nbparallel_;   // total number of parallel threads which will perform the job
 };
 
 //---- Implementation de ParallelTaskInterface pour l'execution des fonctions 
-typedef int (* ParalExFunction) (int);
+//! Prototype for functions which executed by ParallelTaskFunction objects
+typedef int (* ParalExFunction) (int,int);
 //----
-class ParallelTaskFunction {
+  class ParallelTaskFunction : public ParallelTaskInterface {
 public:
   explicit       ParallelTaskFunction(ParalExFunction f);
@@ -116,5 +115,5 @@
   //! Return RC for the ParalleTask.execute() of thread i 
   inline  int     getRC(size_t i) { return vrc_[i]; }
-  //! Return the execption condition for the ParalleTask.execute() of thread i 
+  //! Return the exception condition for the ParalleTask.execute() of thread i 
   inline  bool    IfException(size_t i, string& msg)  { return vpext_[i]->IfException(msg); }
 
