PhoenixThread  1.0.0
Tools to ease parallel programming in C++
Loading...
Searching...
No Matches
PMultiThreadProgress.h
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#ifndef __PMULTITHREADPROGRESS_H__
8#define __PMULTITHREADPROGRESS_H__
9
10#include <string>
11#include <vector>
12#include <map>
13#include <thread>
14
15#include <mutex>
16#include "PString.h"
17
31
33typedef std::vector<ProgressElement> VecProgressElement;
34
37 public:
38 PMultiThreadProgress(size_t nbExpectedProgressBar = 1lu);
40 virtual ~PMultiThreadProgress();
42
43 void setNbExpectedProgressBar(size_t nbExpectedProgressBar);
44
45 size_t addProgressBar(const PString & name, int progressMax = 1);
46 void incrementProgress(size_t index);
47 void setError(size_t index);
48
49 bool isFinished() const;
50 void print();
51 void printSummary() const;
52
53 protected:
55
56 private:
57 void initialisationPMultiThreadProgress(size_t nbExpectedProgressBar);
58 bool isModified();
59 void eraseProgressBar(size_t nbColTerminal);
60 void printProgressBar(size_t nbColTerminal);
62 size_t getNbColTerminal() const;
63
69 std::mutex p_currentMutex;
74};
75
76void phoenix_print_parallel_progress(PMultiThreadProgress & progress, int refreshSecond);
77
78#endif
79
void phoenix_print_parallel_progress(PMultiThreadProgress &progress, int refreshSecond)
Print the parallel progression of the computing.
std::vector< ProgressElement > VecProgressElement
Vector of ProgressElement.
Deal with Progress bar in mutlithread mode.
std::mutex p_currentMutex
Mutex of the class to avoid conflict manipulation between threads.
PMultiThreadProgress & operator=(const PMultiThreadProgress &other)
Definition of equal operator of PMultiThreadProgress.
void printSummary() const
Print a summary of all the progress bars.
size_t p_nbExpectedProgressBar
Number of expected progress bars.
VecProgressElement p_vecProgressElement
Vector of pair (progress, between 0 and 100) and name of progress.
size_t addProgressBar(const PString &name, int progressMax=1)
Add a progress line.
bool isFinished() const
Say if the PMultiThreadProgress is finished.
void print()
Print the multithread progress bar.
PMultiThreadProgress(size_t nbExpectedProgressBar=1lu)
Default constructor of PMultiThreadProgress.
void setNbExpectedProgressBar(size_t nbExpectedProgressBar)
Set the number of expected progress bars in the PMultiThreadProgress.
virtual ~PMultiThreadProgress()
Destructor of PMultiThreadProgress.
bool isModified()
Check if the PMultiThreadProgress has been modified.
void setError(size_t index)
Mark the progress bar at index finished with an error.
void incrementProgress(size_t index)
Increment the progress of the progress bar at index.
void printProgressBar(size_t nbColTerminal)
Print all progress bars.
size_t p_alreadyPrintedLine
Nunmber of already printed line.
void initialisationPMultiThreadProgress(size_t nbExpectedProgressBar)
Initialisation function of the class PMultiThreadProgress.
void eraseProgressBar(size_t nbColTerminal)
Erase all progress bars.
void copyPMultiThreadProgress(const PMultiThreadProgress &other)
Copy function of PMultiThreadProgress.
void printAllFinshedProgressBar()
Print all finished progress bars.
size_t getNbColTerminal() const
Get the number of columns in the current terminal.
size_t p_previousNbProgressBar
Previous number of progress bars.
Single progress information for multithreaded progress bar.
int prevProgress
Previous progression.
PString name
Name of the progress bar.
int progressMax
Maximum of the progression.
bool isEndError
True if the progress ends with an error.
int progress
Current progression.