summaryrefslogtreecommitdiff
path: root/src/error.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.cc')
-rw-r--r--src/error.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/error.cc b/src/error.cc
index b166042..4e3f045 100644
--- a/src/error.cc
+++ b/src/error.cc
@@ -30,12 +30,21 @@ Error::Error()
{
// Initialize
lastError = NULL;
+
+ pthread_mutex_init (&mutex, NULL);
}
Error::~Error()
{
}
+/*
+ pthread_mutex_lock(&mutex);
+ // ... do something
+ pthread_mutex_unlock(&mutex);
+
+ */
+
bool Error::hasError()
{
return lastError != NULL;
@@ -52,17 +61,20 @@ string Error::popAllErrorStrings()
string Error::popErrorString()
{
+ pthread_mutex_lock(&mutex);
if(lastError == NULL) return string("");
_err_entry *err = lastError;
string le = err->errstr;
lastError = err->prev;
delete err;
+ pthread_mutex_unlock(&mutex);
return le;
}
void Error::pushError(char* errstr)
{
+ pthread_mutex_lock(&mutex);
printf("New Error: [%s]\n", errstr);
_err_entry *err = new _err_entry;
@@ -70,19 +82,21 @@ void Error::pushError(char* errstr)
err->errstr = errstr;
err->prev = lastError;
lastError = err;
+ pthread_mutex_unlock(&mutex);
}
void Error::pushError(string &errstr)
{
+ pthread_mutex_lock(&mutex);
_err_entry *err = new _err_entry;
err->errstr = errstr;
err->prev = lastError;
lastError = err;
+ pthread_mutex_unlock(&mutex);
}
void Error::removeAllErrors()
{
while(lastError) popErrorString();
-
}