#ifndef GSATTHREADMPI_HPP 
#define GSATTHREADMPI_HPP 

/* --- Include --- */
#include <vector>
#include <thread>
#include "GSAT/GSAT.hpp"

/* --- Constante --- */
#define DEFAULT_NB_THREAD 4

/* --- Structure --- */
typedef struct {
	int threadId;
	double calcTime;
	unsigned int nbIteration;
	unsigned int heuristicFill;
	unsigned int heuristicSolve;
	unsigned int nbSatisfiedClausesFill;
	unsigned int nbSatisfiedClausesSolve;
}GSATResult;

class GSATThreadMPI {
	public:
		GSATThreadMPI(int, int, char**);
		~GSATThreadMPI();
		bool solve();
		void isEnd();
		/* --- Getter --- */
		inline unsigned int getNbVariables() {return gsat[0]->getNbVariables();}
		inline unsigned int getNbClauses() {return gsat[0]->getNbClauses();}

	private:
		bool end;
		bool find;
		int nbThread;
		std::vector<GSAT*> gsat;
		std::vector<std::thread> threads;
		std::thread mpiSync;
		GSATResult result;

		void solverThread(int);
};

#endif