Logo ROOT   6.08/07
Reference Guide
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ROOT::TProcessExecutor Class Reference

Definition at line 39 of file TProcessExecutor.hxx.

Public Member Functions

 TProcessExecutor (unsigned nWorkers=0)
 Class constructor. More...
 
 TProcessExecutor (const TProcessExecutor &)=delete
 
 ~TProcessExecutor ()=default
 
unsigned GetNWorkers () const
 
template<class F , class Cond = noReferenceCond<F>>
auto Map (F func, unsigned nTimes) -> std::vector< typename std::result_of< F()>::type >
 Execute func (with no arguments) nTimes in parallel. More...
 
TProcessExecutoroperator= (const TProcessExecutor &)=delete
 
template<class F >
auto ProcTree (const std::vector< std::string > &fileNames, F procFunc, const std::string &treeName="", ULong64_t nToProcess=0) -> typename std::result_of< F(std::reference_wrapper< TTreeReader >)>::type
 
template<class F >
auto ProcTree (const std::string &fileName, F procFunc, const std::string &treeName="", ULong64_t nToProcess=0) -> typename std::result_of< F(std::reference_wrapper< TTreeReader >)>::type
 
template<class F >
auto ProcTree (TFileCollection &files, F procFunc, const std::string &treeName="", ULong64_t nToProcess=0) -> typename std::result_of< F(std::reference_wrapper< TTreeReader >)>::type
 
template<class F >
auto ProcTree (TChain &files, F procFunc, const std::string &treeName="", ULong64_t nToProcess=0) -> typename std::result_of< F(std::reference_wrapper< TTreeReader >)>::type
 
template<class F >
auto ProcTree (TTree &tree, F procFunc, ULong64_t nToProcess=0) -> typename std::result_of< F(std::reference_wrapper< TTreeReader >)>::type
 
TListProcTree (const std::vector< std::string > &fileNames, TSelector &selector, const std::string &treeName="", ULong64_t nToProcess=0)
 TSelector-based tree processing: dataset as a vector of files. More...
 
TListProcTree (const std::string &fileName, TSelector &selector, const std::string &treeName="", ULong64_t nToProcess=0)
 TSelector-based tree processing: dataset as a single file. More...
 
TListProcTree (TFileCollection &files, TSelector &selector, const std::string &treeName="", ULong64_t nToProcess=0)
 TSelector-based tree processing: dataset as a TFileCollection. More...
 
TListProcTree (TChain &files, TSelector &selector, const std::string &treeName="", ULong64_t nToProcess=0)
 TSelector-based tree processing: dataset as a TChain. More...
 
TListProcTree (TTree &tree, TSelector &selector, ULong64_t nToProcess=0)
 TSelector-based tree processing: memory resident tree. More...
 
template<class T , class R >
Reduce (const std::vector< T > &objs, R redfunc)
 
void SetNWorkers (unsigned n)
 

Private Types

enum  ETask : unsigned char {
  ETask::kNoTask, ETask::kMap, ETask::kMapWithArg, ETask::kProcByRange,
  ETask::kProcByFile
}
 A collection of the types of tasks that TProcessExecutor can execute. More...
 

Private Member Functions

template<class T >
void Collect (std::vector< T > &reslist)
 Listen for messages sent by the workers and call the appropriate handler function. More...
 
void FixLists (std::vector< TObject *> &lists)
 Fix list of lists before merging (to avoid errors about duplicated objects) More...
 
template<class T >
void HandlePoolCode (MPCodeBufPair &msg, TSocket *sender, std::vector< T > &reslist)
 Handle message and reply to the worker. More...
 
void ReplyToFuncResult (TSocket *s)
 Reply to a worker who just sent a result. More...
 
void ReplyToIdle (TSocket *s)
 Reply to a worker who is idle. More...
 
void Reset ()
 Reset TProcessExecutor's state. More...
 
- Private Member Functions inherited from TMPClient
 TMPClient (unsigned nWorkers=0)
 Class constructor. More...
 
 TMPClient (const TMPClient &)=delete
 
 ~TMPClient ()
 Class destructor. More...
 
unsigned Broadcast (unsigned code, unsigned nMessages=0)
 Send a message with the specified code to at most nMessages workers. More...
 
template<class T >
unsigned Broadcast (unsigned code, const std::vector< T > &objs)
 Send a message with a different object to each server. More...
 
template<class T >
unsigned Broadcast (unsigned code, std::initializer_list< T > &objs)
 Send a message with a different object to each server. More...
 
template<class T >
unsigned Broadcast (unsigned code, T obj, unsigned nMessages=0)
 Send a message containing code and obj to each worker, up to a maximum number of nMessages workers. More...
 
void DeActivate (TSocket *s)
 DeActivate a certain socket. More...
 
bool Fork (TMPWorker &server)
 This method forks the ROOT session into fNWorkers children processes. More...
 
bool GetIsParent () const
 
TMonitorGetMonitor ()
 
unsigned GetNWorkers () const
 
void HandleMPCode (MPCodeBufPair &msg, TSocket *sender)
 Handle messages containing an EMPCode. More...
 
TMPClientoperator= (const TMPClient &)=delete
 
void ReapWorkers ()
 Wait on worker processes and remove their pids from fWorkerPids. More...
 
void Remove (TSocket *s)
 Remove a certain socket from the monitor. More...
 
void SetNWorkers (unsigned n)
 Set the number of workers that will be spawned by the next call to Fork() More...
 

Private Attributes

unsigned fNProcessed
 number of arguments already passed to the workers More...
 
unsigned fNToProcess
 total number of arguments to pass to the workers More...
 
ETask fTaskType = ETask::kNoTask
 the kind of task that is being executed, if any More...
 

#include <ROOT/TProcessExecutor.hxx>

Inheritance diagram for ROOT::TProcessExecutor:
[legend]

Member Enumeration Documentation

◆ ETask

enum ROOT::TProcessExecutor::ETask : unsigned char
strongprivate

A collection of the types of tasks that TProcessExecutor can execute.

It is used to interpret in the right way and properly reply to the messages received (see, for example, TProcessExecutor::HandleInput)

Enumerator
kNoTask 

no task is being executed

kMap 

a Map method with no arguments is being executed

kMapWithArg 

a Map method with arguments is being executed

kProcByRange 

a ProcTree method is being executed and each worker will process a certain range of each file

kProcByFile 

a ProcTree method is being executed and each worker will process a different file

Definition at line 92 of file TProcessExecutor.hxx.

Constructor & Destructor Documentation

◆ TProcessExecutor() [1/2]

TProcessExecutor::TProcessExecutor ( unsigned  nWorkers = 0)
explicit

Class constructor.

nWorkers is the number of times this ROOT session will be forked, i.e. the number of workers that will be spawned.

Definition at line 92 of file TProcessExecutor.cxx.

◆ ~TProcessExecutor()

ROOT::TProcessExecutor::~TProcessExecutor ( )
default

◆ TProcessExecutor() [2/2]

ROOT::TProcessExecutor::TProcessExecutor ( const TProcessExecutor )
delete

Member Function Documentation

◆ Collect()

template<class T >
void TProcessExecutor::Collect ( std::vector< T > &  reslist)
private

Listen for messages sent by the workers and call the appropriate handler function.

TProcessExecutor::HandlePoolCode is called on messages with a code < 1000 and TMPClient::HandleMPCode is called on messages with a code >= 1000.

Definition at line 373 of file TProcessExecutor.hxx.

◆ FixLists()

void TProcessExecutor::FixLists ( std::vector< TObject *> &  lists)
private

Fix list of lists before merging (to avoid errors about duplicated objects)

Definition at line 268 of file TProcessExecutor.cxx.

◆ GetNWorkers()

unsigned ROOT::TProcessExecutor::GetNWorkers ( ) const
inline

Definition at line 73 of file TProcessExecutor.hxx.

◆ HandlePoolCode()

template<class T >
void TProcessExecutor::HandlePoolCode ( MPCodeBufPair msg,
TSocket sender,
std::vector< T > &  reslist 
)
private

Handle message and reply to the worker.

Definition at line 344 of file TProcessExecutor.hxx.

◆ Map()

template<class F , class Cond >
auto TProcessExecutor::Map ( F  func,
unsigned  nTimes 
) -> std::vector<typename std::result_of<F()>::type>

Execute func (with no arguments) nTimes in parallel.

A vector containg executions' results is returned. Functions that take more than zero arguments can be executed (with fixed arguments) by wrapping them in a lambda or with std::bind.

Definition at line 112 of file TProcessExecutor.hxx.

◆ operator=()

TProcessExecutor& ROOT::TProcessExecutor::operator= ( const TProcessExecutor )
delete

◆ ProcTree() [1/10]

template<class F >
auto TProcessExecutor::ProcTree ( const std::vector< std::string > &  fileNames,
F  procFunc,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
) -> typename std::result_of<F(std::reference_wrapper<TTreeReader>)>::type

Definition at line 212 of file TProcessExecutor.hxx.

◆ ProcTree() [2/10]

template<class F >
auto TProcessExecutor::ProcTree ( const std::string &  fileName,
F  procFunc,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
) -> typename std::result_of<F(std::reference_wrapper<TTreeReader>)>::type

Definition at line 266 of file TProcessExecutor.hxx.

◆ ProcTree() [3/10]

template<class F >
auto TProcessExecutor::ProcTree ( TFileCollection files,
F  procFunc,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
) -> typename std::result_of<F(std::reference_wrapper<TTreeReader>)>::type

Definition at line 274 of file TProcessExecutor.hxx.

◆ ProcTree() [4/10]

template<class F >
auto TProcessExecutor::ProcTree ( TChain files,
F  procFunc,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
) -> typename std::result_of<F(std::reference_wrapper<TTreeReader>)>::type

Definition at line 286 of file TProcessExecutor.hxx.

◆ ProcTree() [5/10]

template<class F >
auto TProcessExecutor::ProcTree ( TTree tree,
F  procFunc,
ULong64_t  nToProcess = 0 
) -> typename std::result_of<F(std::reference_wrapper<TTreeReader>)>::type

Definition at line 299 of file TProcessExecutor.hxx.

◆ ProcTree() [6/10]

TList * TProcessExecutor::ProcTree ( const std::vector< std::string > &  fileNames,
TSelector selector,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
)

TSelector-based tree processing: dataset as a vector of files.

Definition at line 153 of file TProcessExecutor.cxx.

◆ ProcTree() [7/10]

TList * TProcessExecutor::ProcTree ( const std::string &  fileName,
TSelector selector,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
)

TSelector-based tree processing: dataset as a single file.

Definition at line 261 of file TProcessExecutor.cxx.

◆ ProcTree() [8/10]

TList * TProcessExecutor::ProcTree ( TFileCollection files,
TSelector selector,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
)

TSelector-based tree processing: dataset as a TFileCollection.

Definition at line 235 of file TProcessExecutor.cxx.

◆ ProcTree() [9/10]

TList * TProcessExecutor::ProcTree ( TChain files,
TSelector selector,
const std::string &  treeName = "",
ULong64_t  nToProcess = 0 
)

TSelector-based tree processing: dataset as a TChain.

Definition at line 248 of file TProcessExecutor.cxx.

◆ ProcTree() [10/10]

TList * TProcessExecutor::ProcTree ( TTree tree,
TSelector selector,
ULong64_t  nToProcess = 0 
)

TSelector-based tree processing: memory resident tree.

Definition at line 99 of file TProcessExecutor.cxx.

◆ Reduce()

template<class T , class R >
T TProcessExecutor::Reduce ( const std::vector< T > &  objs,
R  redfunc 
)

Definition at line 204 of file TProcessExecutor.hxx.

◆ ReplyToFuncResult()

void TProcessExecutor::ReplyToFuncResult ( TSocket s)
private

Reply to a worker who just sent a result.

If another argument to process exists, tell the worker. Otherwise send a shutdown order.

Definition at line 296 of file TProcessExecutor.cxx.

◆ ReplyToIdle()

void TProcessExecutor::ReplyToIdle ( TSocket s)
private

Reply to a worker who is idle.

If another argument to process exists, tell the worker. Otherwise ask for a result

Definition at line 314 of file TProcessExecutor.cxx.

◆ Reset()

void TProcessExecutor::Reset ( void  )
private

Reset TProcessExecutor's state.

Definition at line 284 of file TProcessExecutor.cxx.

◆ SetNWorkers()

void ROOT::TProcessExecutor::SetNWorkers ( unsigned  n)
inline

Definition at line 72 of file TProcessExecutor.hxx.

Member Data Documentation

◆ fNProcessed

unsigned ROOT::TProcessExecutor::fNProcessed
private

number of arguments already passed to the workers

Definition at line 86 of file TProcessExecutor.hxx.

◆ fNToProcess

unsigned ROOT::TProcessExecutor::fNToProcess
private

total number of arguments to pass to the workers

Definition at line 87 of file TProcessExecutor.hxx.

◆ fTaskType

ETask ROOT::TProcessExecutor::fTaskType = ETask::kNoTask
private

the kind of task that is being executed, if any

Definition at line 100 of file TProcessExecutor.hxx.


The documentation for this class was generated from the following files: