Use std::mutex instead of ArchMutex in Log
This commit is contained in:
parent
9df4741748
commit
d9d39040ae
|
@ -63,9 +63,6 @@ Log::Log()
|
|||
{
|
||||
assert(s_log == NULL);
|
||||
|
||||
// create mutex for multithread safe operation
|
||||
m_mutex = ARCH->newMutex();
|
||||
|
||||
// other initalization
|
||||
m_maxPriority = g_defaultMaxPriority;
|
||||
m_maxNewlineLength = 0;
|
||||
|
@ -90,7 +87,6 @@ Log::~Log()
|
|||
index != m_alwaysOutputters.end(); ++index) {
|
||||
delete *index;
|
||||
}
|
||||
ARCH->closeMutex(m_mutex);
|
||||
}
|
||||
|
||||
Log*
|
||||
|
@ -214,7 +210,7 @@ Log::insert(ILogOutputter* outputter, bool alwaysAtHead)
|
|||
{
|
||||
assert(outputter != NULL);
|
||||
|
||||
ArchMutexLock lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (alwaysAtHead) {
|
||||
m_alwaysOutputters.push_front(outputter);
|
||||
}
|
||||
|
@ -237,7 +233,7 @@ Log::insert(ILogOutputter* outputter, bool alwaysAtHead)
|
|||
void
|
||||
Log::remove(ILogOutputter* outputter)
|
||||
{
|
||||
ArchMutexLock lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_outputters.remove(outputter);
|
||||
m_alwaysOutputters.remove(outputter);
|
||||
}
|
||||
|
@ -245,7 +241,7 @@ Log::remove(ILogOutputter* outputter)
|
|||
void
|
||||
Log::pop_front(bool alwaysAtHead)
|
||||
{
|
||||
ArchMutexLock lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
OutputterList* list = alwaysAtHead ? &m_alwaysOutputters : &m_outputters;
|
||||
if (!list->empty()) {
|
||||
delete list->front();
|
||||
|
@ -271,14 +267,14 @@ Log::setFilter(const char* maxPriority)
|
|||
void
|
||||
Log::setFilter(int maxPriority)
|
||||
{
|
||||
ArchMutexLock lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_maxPriority = maxPriority;
|
||||
}
|
||||
|
||||
int
|
||||
Log::getFilter() const
|
||||
{
|
||||
ArchMutexLock lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return m_maxPriority;
|
||||
}
|
||||
|
||||
|
@ -289,7 +285,7 @@ Log::output(ELevel priority, char* msg)
|
|||
assert(msg != NULL);
|
||||
if (!msg) return;
|
||||
|
||||
ArchMutexLock lock(m_mutex);
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
OutputterList::const_iterator i;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "common/stdlist.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <mutex>
|
||||
|
||||
#define CLOG (Log::getInstance())
|
||||
#define BYE "\nTry `%s --help' for more information."
|
||||
|
@ -132,7 +133,7 @@ private:
|
|||
|
||||
static Log* s_log;
|
||||
|
||||
ArchMutex m_mutex;
|
||||
mutable std::mutex m_mutex;
|
||||
OutputterList m_outputters;
|
||||
OutputterList m_alwaysOutputters;
|
||||
int m_maxNewlineLength;
|
||||
|
|
Loading…
Reference in New Issue