Added mutex lock to log output.
This commit is contained in:
parent
64afc5ab9f
commit
4286a7b449
@ -14,7 +14,5 @@ namespace coreutils {
|
|||||||
|
|
||||||
Log(LOG_EXCEPT) << text;
|
Log(LOG_EXCEPT) << text;
|
||||||
}
|
}
|
||||||
|
|
||||||
Exception::~Exception() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ namespace coreutils {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Exception(std::string text, std::string file = __FILE__, int line = __LINE__, int errorNumber = -1);
|
Exception(std::string text, std::string file = __FILE__, int line = __LINE__, int errorNumber = -1);
|
||||||
~Exception();
|
|
||||||
|
|
||||||
std::string className;
|
std::string className;
|
||||||
std::string file;
|
std::string file;
|
||||||
|
4
Log.cpp
4
Log.cpp
@ -61,6 +61,8 @@ namespace coreutils {
|
|||||||
Log::~Log() {
|
Log::~Log() {
|
||||||
|
|
||||||
if(output) {
|
if(output) {
|
||||||
|
|
||||||
|
mtx.lock();
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << seq << "." << this->str() << std::endl;;
|
out << seq << "." << this->str() << std::endl;;
|
||||||
@ -73,6 +75,8 @@ namespace coreutils {
|
|||||||
|
|
||||||
std::cout << out.str();
|
std::cout << out.str();
|
||||||
++seq;
|
++seq;
|
||||||
|
|
||||||
|
mtx.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
Log.h
3
Log.h
@ -86,6 +86,9 @@ namespace coreutils {
|
|||||||
///
|
///
|
||||||
|
|
||||||
static int seq;
|
static int seq;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::mutex mtx;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
2
compile
2
compile
@ -5,7 +5,7 @@ do
|
|||||||
filename="${file%.*}"
|
filename="${file%.*}"
|
||||||
list="$list $filename.o"
|
list="$list $filename.o"
|
||||||
echo -n "Compiling $filename..."
|
echo -n "Compiling $filename..."
|
||||||
g++ -c $file &
|
g++ -g -c $file
|
||||||
if [ $? = '0' ]
|
if [ $? = '0' ]
|
||||||
then
|
then
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user