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:
crs
2002-05-31 14:25:26 +00:00
parent 70f5f9491d
commit 536eb52337
4 changed files with 184 additions and 19 deletions

View File

@@ -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"