mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Use a semaphore in plStatusLog.
This commit is contained in:
@ -70,10 +70,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "plEncryptLogLine.h"
|
||||
|
||||
#if HS_BUILD_FOR_UNIX
|
||||
#include <limits.h>
|
||||
#define MAX_PATH PATH_MAX
|
||||
#elif HS_BUILD_FOR_WIN32
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
#include <Shlobj.h>
|
||||
#endif
|
||||
|
||||
@ -411,6 +408,7 @@ uint32_t plStatusLog::fLoggingOff = false;
|
||||
plStatusLog::plStatusLog( uint8_t numDisplayLines, const wchar_t *filename, uint32_t flags )
|
||||
{
|
||||
fFileHandle = nil;
|
||||
fSema = nil;
|
||||
fSize = 0;
|
||||
fForceLog = false;
|
||||
|
||||
@ -421,12 +419,16 @@ plStatusLog::plStatusLog( uint8_t numDisplayLines, const wchar_t *filename, uint
|
||||
char* temp = hsWStringToString(filename);
|
||||
fCFilename = temp;
|
||||
delete [] temp;
|
||||
|
||||
fSema = new hsSemaphore(1, fCFilename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
fFilename = L"";
|
||||
fCFilename = "";
|
||||
flags |= kDontWriteFile;
|
||||
|
||||
fSema = new hsSemaphore(1);
|
||||
}
|
||||
|
||||
fOrigFlags = fFlags = flags;
|
||||
@ -532,6 +534,9 @@ void plStatusLog::IFini( void )
|
||||
for( i = 0; i < fMaxNumLines; i++ )
|
||||
delete [] fLines[ i ];
|
||||
|
||||
if (fSema)
|
||||
delete fSema;
|
||||
|
||||
delete [] fLines;
|
||||
delete [] fColors;
|
||||
}
|
||||
@ -601,7 +606,7 @@ bool plStatusLog::IAddLine( const char *line, int32_t count, uint32_t color )
|
||||
return true;
|
||||
|
||||
/// Scroll pointers up
|
||||
hsTempMutexLock lock( fMutex );
|
||||
fSema->Wait();
|
||||
|
||||
bool ret = true;
|
||||
|
||||
@ -649,6 +654,8 @@ bool plStatusLog::IAddLine( const char *line, int32_t count, uint32_t color )
|
||||
ret = IPrintLineToFile( line, count );
|
||||
}
|
||||
|
||||
fSema->Signal();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -82,16 +82,16 @@ class plStatusLog
|
||||
mutable uint32_t fFlags; // Mutable so we can change it in IPrintLineToFile() internally
|
||||
uint32_t fOrigFlags;
|
||||
|
||||
uint32_t fMaxNumLines;
|
||||
std::string fCFilename; // used ONLY by GetFileName()
|
||||
uint32_t fMaxNumLines;
|
||||
std::string fCFilename; // used ONLY by GetFileName()
|
||||
std::wstring fFilename;
|
||||
char **fLines;
|
||||
uint32_t *fColors;
|
||||
hsMutex fMutex; // To make multithreaded-safe
|
||||
FILE* fFileHandle;
|
||||
uint32_t fSize;
|
||||
bool fEncryptMe;
|
||||
bool fForceLog;
|
||||
char** fLines;
|
||||
uint32_t* fColors;
|
||||
hsSemaphore* fSema;
|
||||
FILE* fFileHandle;
|
||||
uint32_t fSize;
|
||||
bool fEncryptMe;
|
||||
bool fForceLog;
|
||||
|
||||
plStatusLog *fNext, **fBack;
|
||||
|
||||
|
Reference in New Issue
Block a user