Commit 992dcda5 authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Fix GUI according to rebase

parent 2e46593c
Loading
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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);
+8 −1
Original line number Diff line number Diff line
@@ -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;
};


+0 −2
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ struct ThreadData {
	uint limitAdvancedmask;

	SecurityRules sr;

	bool finished = false;
};

#endif // THREAD_DATA_H
 No newline at end of file
+7 −3
Original line number Diff line number Diff line
@@ -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];
		}