//Processing the results of search done by each thread and constructing  a response
void StringProcessor::processMessages(){
	sout << "\nIn string processor for string : " << srchString;

	try{
		int j = 0;
		Timer timer; timer.start();

		while (true){
			SearchResult sr = bqOut.deQ();
			if (sr.isFound()){
				filesFoundIn.push_back(sr.getFile());
			}
			//construct response
			j++;
			if (j == numFiles){
				//sout << "\nexiting from string processor";
				break;
			}
			/*for (std::thread* thrd : threads){
				thrd->join();
			}*/
			/*if (bqOut.isEmpty()){
				sout << "\nExiting from string processor\n";
				break;
				}*/
		}
		timer.stop();
		elapsedTime  = timer.elapsedTime<std::chrono::milliseconds>();
		constructResponse();

	}catch (exception e){
		sout << e.what();
	}
}
//Processing that goes on in each thread
void StringProcessor::search(){
	try{
		ostringstream ossStart;
		ossStart << "\n Started Thread ID : " << std::this_thread::get_id() << " \n";
		sout << ossStart.str();

		while (true){
			if (bqIn.isEmpty()){
				ostringstream ossEnd;
				ossEnd << "\n Exiting from Thread ID : " << std::this_thread::get_id() << " \n";
				sout << ossEnd.str();

				return;
			}
			SearchResult sr = bqIn.deQ();
			ostringstream ossProcess;
			ossProcess << "\n Processing in Thread ID : " << std::this_thread::get_id() << " file " << sr.getFile() << " for string " << srchString << "\n";
			sout << ossProcess.str();
			if (searchStr(sr.getFile(), srchString)){
				sr.setFound(true);
			}
			else{
				sr.setFound(false);
			}
			bqOut.enQ(sr);
			if (sr.isFound()){
				thread::id tid = (std::this_thread::get_id());
				stringstream ss;
				ss << tid;
				string msg = "\nIn  thread " + ss.str() + " found \"" + srchString + "\" in file " + sr.getFile() + "\n";
				sout << msg;
				//filesFoundIn.push_back(sr.getFile());
			}
		}
	}catch (exception e){
		sout << e.what();
	}
}