mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-10 13:45:49 +08:00
added methods to CLog for getting the outputter, getting and
setting the priority filter, and added code for thread safety. added code to apps to enable thread safety in CLog.
This commit is contained in:
@@ -1,11 +1,44 @@
|
||||
#include "CServer.h"
|
||||
#include "CScreenMap.h"
|
||||
#include "CThread.h"
|
||||
#include "CLog.h"
|
||||
#include "CMutex.h"
|
||||
#include "CNetwork.h"
|
||||
#include "CThread.h"
|
||||
|
||||
//
|
||||
// logging thread safety
|
||||
//
|
||||
|
||||
static CMutex* s_logMutex = NULL;
|
||||
|
||||
static void logLock(bool lock)
|
||||
{
|
||||
assert(s_logMutex != NULL);
|
||||
|
||||
if (lock) {
|
||||
s_logMutex->lock();
|
||||
}
|
||||
else {
|
||||
s_logMutex->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// main
|
||||
//
|
||||
|
||||
void realMain()
|
||||
{
|
||||
// initialize threading library
|
||||
CThread::init();
|
||||
|
||||
// make logging thread safe
|
||||
CMutex logMutex;
|
||||
s_logMutex = &logMutex;
|
||||
CLog::setLock(&logLock);
|
||||
|
||||
// initialize network library
|
||||
CNetwork::init();
|
||||
|
||||
CScreenMap screenMap;
|
||||
@@ -24,14 +57,23 @@ void realMain()
|
||||
server->run();
|
||||
delete server;
|
||||
CNetwork::cleanup();
|
||||
CLog::setLock(NULL);
|
||||
s_logMutex = NULL;
|
||||
}
|
||||
catch (...) {
|
||||
delete server;
|
||||
CNetwork::cleanup();
|
||||
CLog::setLock(NULL);
|
||||
s_logMutex = NULL;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// platform dependent entry points
|
||||
//
|
||||
|
||||
#if defined(CONFIG_PLATFORM_WIN32)
|
||||
|
||||
#include "CMSWindowsScreen.h"
|
||||
|
||||
Reference in New Issue
Block a user