Skip to content
Snippets Groups Projects
Commit 992dcda5 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Fix GUI according to rebase

parent 2e46593c
No related branches found
No related tags found
No related merge requests found
Pipeline #6302 passed
......@@ -30,19 +30,18 @@ class ProgressThread : public QThread
uint64_t processed = 0;
int finished = 0;
const int nbthreads = _s.getNbThreads();
const struct thread_data* td = _s.getThreadsData();
const struct ThreadData* td = _s.getThreadsData();
while(td[nbthreads-1].lineEnd == 0){
while(!_s.allStarted()){
msleep(500);
}
const uint64_t nblines = td[nbthreads-1].lineEnd;
while(finished != nbthreads){
while(!_s.allFinished()){
processed = 0;
finished = 0;
for(int i=0; i < nbthreads; ++i){
processed += td[i].total_counter;
finished += td[i].finished;
}
progress = (int) percentage(processed, nblines);
_qpb.setValue(progress);
......
......@@ -144,6 +144,8 @@ public:
inline const StringOccurrence& getStatsSimple() const { return stats_simplemasks; }
inline const StringOccurrence& getStatsAdvanced() const { return stats_advancedmasks; }
inline const ThreadData* getThreadsData() const { return td; }
inline bool allFinished() const { return finished == nbThread; }
inline bool allStarted() const { return started; }
private:
std::string filename;
......@@ -158,7 +160,7 @@ private:
bool withcount = false; // Know if the database is at the format withcount or not
int limitSimplemask = 12; // Limit the size of Simple Mask
int limitAdvancedmask = 12; // Limit the size of Advanced Mask
int nbThread = 1; // Number of usable threads, default 1
uint nbThread = 1; // Number of usable threads, default 1
std::string outfile_name; // File where to write masks
bool is_stdin = false; // If filename is stdin
bool debug_enabled = false; // Enable debug output
......@@ -182,6 +184,11 @@ private:
// Security policy
SecurityRules _sr = { 0, 8, 0, 1, 1, 1 };
// threads which have finished
uint finished = 0;
// all threads have been started
bool started = false;
};
......
......@@ -54,8 +54,6 @@ struct ThreadData {
uint limitAdvancedmask;
SecurityRules sr;
bool finished = false;
};
#endif // THREAD_DATA_H
\ No newline at end of file
......@@ -63,6 +63,8 @@ void Statsgen::configureThread(ThreadData& td) const {
}
int Statsgen::generate_stats() {
finished = 0;
started = false;
uint64_t nbline = 0;
if (!is_stdin){
nbline = nbline_file(filename);
......@@ -84,7 +86,7 @@ int Statsgen::generate_stats() {
}
}
for(int i = 0; i < nbThread; i++ ) {
for(uint i = 0; i < nbThread; i++ ) {
td[i].thread_id = i + 1;
configureThread(td[i]);
......@@ -116,14 +118,16 @@ int Statsgen::generate_stats() {
}
}
started = true;
void *status;
for(int i = 0; i < nbThread; i++ ) {
for(uint i = 0; i < nbThread; i++ ) {
int rc = pthread_join(threads[i], &status);
if (rc) {
cerr << "[ERROR] unable to join," << rc << endl;
exit(-1);
}
td[i].finished = true;
finished++;
if(i >= 1){
td[0] += td[i];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment