PhoenixThread  1.0.0
Tools to ease parallel programming in C++
Loading...
Searching...
No Matches
phoenix_program_call.h File Reference
#include "ProgramCall.h"
+ Include dependency graph for phoenix_program_call.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef std::vector< ProgramCallVecProgramCall
 Vector of program call.
 
typedef std::vector< VecProgramCallVecVecProgramCall
 Vector of vector of program call.
 

Functions

void phoenix_program_addcall (VecProgramCall &vecCall, const PString &name, const PString &command, const PPath &workingDirectory=PPath("./"), const PPath &logFile=PPath())
 Add a program call.
 
void phoenix_program_call (ProgramCall &call)
 Call a program.
 
void phoenix_program_callParallel (VecProgramCall &vecCall, size_t nbThread)
 Exectute programs on several threads.
 
void phoenix_program_callParallelProgressBar (VecProgramCall &vecCall, size_t nbThread)
 Exectute programs on several threads (with a multithread progress bar)
 
void phoenix_program_callParallelProgressBar (VecVecProgramCall &vecVecProgramCall)
 Exectute programs on several threads (with a multithread progress bar)
 
void phoenix_program_callVec (VecProgramCall &vecCall)
 Call a vector of program.
 
size_t phoenix_program_getNbCall (const VecVecProgramCall &vecCall)
 Get the number of call.
 
size_t phoenix_program_getNbCallExitStatusType (const VecProgramCall &vecCall, int result)
 Get number of call result of a given type.
 
size_t phoenix_program_getNbCallExitStatusType (const VecVecProgramCall &vecCall, int result)
 Get number of call result of a given type.
 
size_t phoenix_program_getNbSuccessCall (const VecProgramCall &vecCall)
 Get the number of success call.
 
size_t phoenix_program_getNbSuccessCall (const VecVecProgramCall &vecCall)
 Get the number of success call.
 

Typedef Documentation

◆ VecProgramCall

typedef std::vector<ProgramCall> VecProgramCall

Vector of program call.

Definition at line 13 of file phoenix_program_call.h.

◆ VecVecProgramCall

typedef std::vector<VecProgramCall> VecVecProgramCall

Vector of vector of program call.

Definition at line 15 of file phoenix_program_call.h.

Function Documentation

◆ phoenix_program_addcall()

void phoenix_program_addcall ( VecProgramCall & vecCall,
const PString & name,
const PString & command,
const PPath & workingDirectory,
const PPath & logFile )

Add a program call.

Parameters
[out]vecCall: vector of program call
name: name of the call
command: command of the call
workingDirectory: directory in which to call the program
logFile: log file of the call

Definition at line 108 of file phoenix_program_call.cpp.

110{
111 ProgramCall call;
112 call.setName(name);
113 call.setCommand(command);
114 call.setWorkingDirectory(workingDirectory);
115 call.setLogFile(logFile);
116 call.setExitStatus(0);
117 vecCall.push_back(call);
118}
Call a program.
Definition ProgramCall.h:14
void setLogFile(const PPath &logFile)
Sets the logFile of the ProgramCall.
void setName(const PString &name)
Sets the name of the ProgramCall.
void setExitStatus(int exitStatus)
Sets the exitStatus of the ProgramCall.
void setCommand(const PString &command)
Sets the command of the ProgramCall.
void setWorkingDirectory(const PPath &workingDirectory)
Sets the workingDirectory of the ProgramCall.

References ProgramCall::setCommand(), ProgramCall::setExitStatus(), ProgramCall::setLogFile(), ProgramCall::setName(), and ProgramCall::setWorkingDirectory().

+ Here is the call graph for this function:

◆ phoenix_program_call()

void phoenix_program_call ( ProgramCall & call)

Call a program.

Parameters
[out]call: program to be executed

Definition at line 23 of file phoenix_program_call.cpp.

23 {
24 PString command(call.getCommand());
25 if(call.getWorkingDirectory() != ""){
26 command = "cd " + PString(call.getWorkingDirectory()) + ";" + command;
27 }
28 if(call.getLogFile() != ""){
29 PString logContent("");
30 call.setExitStatus(phoenix_popen(logContent, command));
31 call.getLogFile().saveFileContent(logContent);
32 }else{
33 std::cout << termCyan() << "Call command '"<<command<<"'" << termDefault() << std::endl;
34 call.setExitStatus(system(command.c_str()));
35 }
36}
const PPath & getLogFile() const
Gets the logFile of the ProgramCall.
const PPath & getWorkingDirectory() const
Gets the workingDirectory of the ProgramCall.
const PString & getCommand() const
Gets the command of the ProgramCall.

References ProgramCall::getCommand(), ProgramCall::getLogFile(), ProgramCall::getWorkingDirectory(), and ProgramCall::setExitStatus().

Referenced by phoenix_program_callVec(), and phoenix_program_callVecProgress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_program_callParallel()

void phoenix_program_callParallel ( VecProgramCall & vecCall,
size_t nbThread )

Exectute programs on several threads.

Parameters
[out]vecCall: vector of commands to be exectuted
nbThread: number of thread to be used

Definition at line 51 of file phoenix_program_call.cpp.

51 {
52 if(vecCall.size() == 0lu){return;}
54}
void lauchParallelThread(const std::vector< T > &listInputPTabModelFile, long unsigned int nbThread, _Callable &&__f, _Args &&... __args)
Lauch the callable function __f on nbThread threads with __args to be passed to each thread.
void phoenix_program_callVec(VecProgramCall &vecCall)
Call a vector of program.

References lauchParallelThread(), and phoenix_program_callVec().

+ Here is the call graph for this function:

◆ phoenix_program_callParallelProgressBar() [1/2]

void phoenix_program_callParallelProgressBar ( VecProgramCall & vecCall,
size_t nbThread )

Exectute programs on several threads (with a multithread progress bar)

Parameters
[out]vecCall: vector of commands to be exectuted
nbThread: number of thread to be used

Definition at line 94 of file phoenix_program_call.cpp.

94 {
95 if(vecCall.size() == 0lu){return;}
96 VecVecProgramCall vecVecProgramCall;
97 phoenix_vector_split(vecVecProgramCall, vecCall, nbThread);
99}
void phoenix_program_callParallelProgressBar(VecVecProgramCall &vecVecProgramCall)
Exectute programs on several threads (with a multithread progress bar)
std::vector< VecProgramCall > VecVecProgramCall
Vector of vector of program call.

References phoenix_program_callParallelProgressBar().

+ Here is the call graph for this function:

◆ phoenix_program_callParallelProgressBar() [2/2]

void phoenix_program_callParallelProgressBar ( VecVecProgramCall & vecVecProgramCall)

Exectute programs on several threads (with a multithread progress bar)

Parameters
[out]vecVecProgramCall: vector of commands to be exectuted (already split over threads)

Definition at line 72 of file phoenix_program_call.cpp.

72 {
73 size_t nbThread = vecVecProgramCall.size(); //In case we need less thread than required
74 PMultiThreadProgress progress(nbThread);
75 std::vector<std::thread> vecThread;
76 vecThread.resize(nbThread);
77 std::thread threadProgress(phoenix_print_parallel_progress, std::ref(progress), 1);
78 for(size_t i(0lu); i < nbThread; ++i){
79 vecThread[i] = std::thread(phoenix_program_callVecProgress, std::ref(progress), std::ref(vecVecProgramCall[i]), i);
80 }
81 threadProgress.join();
82 for(size_t i(0lu); i < nbThread; ++i){
83 vecThread[i].join();
84 }
85 size_t nbSuccess(phoenix_program_getNbSuccessCall(vecVecProgramCall));
86 size_t nbFail(phoenix_program_getNbCall(vecVecProgramCall) - nbSuccess);
87 std::cout << "VecProgramCall : summary : " << nbSuccess << " success, " << nbFail << " fail" << std::endl;
88}
void phoenix_print_parallel_progress(PMultiThreadProgress &progress, int refreshSecond)
Print the parallel progression of the computing.
Deal with Progress bar in mutlithread mode.
size_t phoenix_program_getNbSuccessCall(const VecProgramCall &vecCall)
Get the number of success call.
void phoenix_program_callVecProgress(PMultiThreadProgress &progress, VecProgramCall &vecCall, size_t threadIndex)
Call a vector of program.
size_t phoenix_program_getNbCall(const VecVecProgramCall &vecCall)
Get the number of call.

References phoenix_print_parallel_progress(), phoenix_program_callVecProgress(), phoenix_program_getNbCall(), and phoenix_program_getNbSuccessCall().

Referenced by phoenix_program_callParallelProgressBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_program_callVec()

void phoenix_program_callVec ( VecProgramCall & vecCall)

Call a vector of program.

Parameters
[out]vecCall: vector of program to be executed

Definition at line 41 of file phoenix_program_call.cpp.

41 {
42 for(VecProgramCall::iterator it(vecCall.begin()); it != vecCall.end(); ++it){
44 }
45}
void phoenix_program_call(ProgramCall &call)
Call a program.

References phoenix_program_call().

Referenced by phoenix_program_callParallel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_program_getNbCall()

size_t phoenix_program_getNbCall ( const VecVecProgramCall & vecCall)

Get the number of call.

Parameters
vecCall: vector of vector of call
Returns
number of call

Definition at line 166 of file phoenix_program_call.cpp.

166 {
167 size_t nbCall(0lu);
168 for(VecVecProgramCall::const_iterator it(vecCall.begin()); it != vecCall.end(); ++it){
169 nbCall += it->size();
170 }
171 return nbCall;
172}

Referenced by phoenix_program_callParallelProgressBar().

+ Here is the caller graph for this function:

◆ phoenix_program_getNbCallExitStatusType() [1/2]

size_t phoenix_program_getNbCallExitStatusType ( const VecProgramCall & vecCall,
int result )

Get number of call result of a given type.

Parameters
vecCall: vector of call
result: expected result
Returns
number of call with given result

Definition at line 125 of file phoenix_program_call.cpp.

125 {
126 size_t nbSuccessCall(0lu);
127 for(VecProgramCall::const_iterator it(vecCall.begin()); it != vecCall.end(); ++it){
128 nbSuccessCall += it->getExitStatus() == result;
129 }
130 return nbSuccessCall;
131}

Referenced by phoenix_program_getNbCallExitStatusType(), phoenix_program_getNbSuccessCall(), and phoenix_program_getNbSuccessCall().

+ Here is the caller graph for this function:

◆ phoenix_program_getNbCallExitStatusType() [2/2]

size_t phoenix_program_getNbCallExitStatusType ( const VecVecProgramCall & vecCall,
int result )

Get number of call result of a given type.

Parameters
vecCall: vector of vector of call
result: expected result
Returns
number of call with given result

Definition at line 138 of file phoenix_program_call.cpp.

138 {
139 size_t nbSuccessCall(0lu);
140 for(VecVecProgramCall::const_iterator it(vecCall.begin()); it != vecCall.end(); ++it){
141 nbSuccessCall += phoenix_program_getNbCallExitStatusType(*it, result);
142 }
143 return nbSuccessCall;
144}
size_t phoenix_program_getNbCallExitStatusType(const VecProgramCall &vecCall, int result)
Get number of call result of a given type.

References phoenix_program_getNbCallExitStatusType().

+ Here is the call graph for this function:

◆ phoenix_program_getNbSuccessCall() [1/2]

size_t phoenix_program_getNbSuccessCall ( const VecProgramCall & vecCall)

Get the number of success call.

Parameters
vecCall: vector of call
Returns
number of success call

Definition at line 150 of file phoenix_program_call.cpp.

150 {
152}

References phoenix_program_getNbCallExitStatusType().

Referenced by phoenix_program_callParallelProgressBar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_program_getNbSuccessCall() [2/2]

size_t phoenix_program_getNbSuccessCall ( const VecVecProgramCall & vecCall)

Get the number of success call.

Parameters
vecCall: vector of vector of call
Returns
number of success call

Definition at line 158 of file phoenix_program_call.cpp.

158 {
160}

References phoenix_program_getNbCallExitStatusType().

+ Here is the call graph for this function: