Added mutex lock to log output.

This commit is contained in:
Brad Arant 2019-10-20 09:32:11 -07:00
parent 64afc5ab9f
commit 4286a7b449
6 changed files with 9 additions and 5 deletions

View File

@ -14,7 +14,5 @@ namespace coreutils {
Log(LOG_EXCEPT) << text;
}
Exception::~Exception() {}
}

View File

@ -9,7 +9,6 @@ namespace coreutils {
public:
Exception(std::string text, std::string file = __FILE__, int line = __LINE__, int errorNumber = -1);
~Exception();
std::string className;
std::string file;

View File

@ -61,6 +61,8 @@ namespace coreutils {
Log::~Log() {
if(output) {
mtx.lock();
std::stringstream out;
out << seq << "." << this->str() << std::endl;;
@ -73,6 +75,8 @@ namespace coreutils {
std::cout << out.str();
++seq;
mtx.unlock();
}
}

3
Log.h
View File

@ -86,6 +86,9 @@ namespace coreutils {
///
static int seq;
private:
std::mutex mtx;
};

View File

@ -5,7 +5,7 @@ do
filename="${file%.*}"
list="$list $filename.o"
echo -n "Compiling $filename..."
g++ -c $file &
g++ -g -c $file
if [ $? = '0' ]
then
echo "OK"

View File

@ -1,4 +1,4 @@
#define _GLIBCXX_USE_CXX11_ABI 0
#include <iostream>
#include <vector>