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"
|
#include "plEncryptLogLine.h"
|
||||||
|
|
||||||
#if HS_BUILD_FOR_UNIX
|
#if HS_BUILD_FOR_WIN32
|
||||||
#include <limits.h>
|
|
||||||
#define MAX_PATH PATH_MAX
|
|
||||||
#elif HS_BUILD_FOR_WIN32
|
|
||||||
#include <Shlobj.h>
|
#include <Shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -411,6 +408,7 @@ uint32_t plStatusLog::fLoggingOff = false;
|
|||||||
plStatusLog::plStatusLog( uint8_t numDisplayLines, const wchar_t *filename, uint32_t flags )
|
plStatusLog::plStatusLog( uint8_t numDisplayLines, const wchar_t *filename, uint32_t flags )
|
||||||
{
|
{
|
||||||
fFileHandle = nil;
|
fFileHandle = nil;
|
||||||
|
fSema = nil;
|
||||||
fSize = 0;
|
fSize = 0;
|
||||||
fForceLog = false;
|
fForceLog = false;
|
||||||
|
|
||||||
@ -421,12 +419,16 @@ plStatusLog::plStatusLog( uint8_t numDisplayLines, const wchar_t *filename, uint
|
|||||||
char* temp = hsWStringToString(filename);
|
char* temp = hsWStringToString(filename);
|
||||||
fCFilename = temp;
|
fCFilename = temp;
|
||||||
delete [] temp;
|
delete [] temp;
|
||||||
|
|
||||||
|
fSema = new hsSemaphore(1, fCFilename.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fFilename = L"";
|
fFilename = L"";
|
||||||
fCFilename = "";
|
fCFilename = "";
|
||||||
flags |= kDontWriteFile;
|
flags |= kDontWriteFile;
|
||||||
|
|
||||||
|
fSema = new hsSemaphore(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fOrigFlags = fFlags = flags;
|
fOrigFlags = fFlags = flags;
|
||||||
@ -532,6 +534,9 @@ void plStatusLog::IFini( void )
|
|||||||
for( i = 0; i < fMaxNumLines; i++ )
|
for( i = 0; i < fMaxNumLines; i++ )
|
||||||
delete [] fLines[ i ];
|
delete [] fLines[ i ];
|
||||||
|
|
||||||
|
if (fSema)
|
||||||
|
delete fSema;
|
||||||
|
|
||||||
delete [] fLines;
|
delete [] fLines;
|
||||||
delete [] fColors;
|
delete [] fColors;
|
||||||
}
|
}
|
||||||
@ -601,7 +606,7 @@ bool plStatusLog::IAddLine( const char *line, int32_t count, uint32_t color )
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
/// Scroll pointers up
|
/// Scroll pointers up
|
||||||
hsTempMutexLock lock( fMutex );
|
fSema->Wait();
|
||||||
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
@ -649,6 +654,8 @@ bool plStatusLog::IAddLine( const char *line, int32_t count, uint32_t color )
|
|||||||
ret = IPrintLineToFile( line, count );
|
ret = IPrintLineToFile( line, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fSema->Signal();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,16 +82,16 @@ class plStatusLog
|
|||||||
mutable uint32_t fFlags; // Mutable so we can change it in IPrintLineToFile() internally
|
mutable uint32_t fFlags; // Mutable so we can change it in IPrintLineToFile() internally
|
||||||
uint32_t fOrigFlags;
|
uint32_t fOrigFlags;
|
||||||
|
|
||||||
uint32_t fMaxNumLines;
|
uint32_t fMaxNumLines;
|
||||||
std::string fCFilename; // used ONLY by GetFileName()
|
std::string fCFilename; // used ONLY by GetFileName()
|
||||||
std::wstring fFilename;
|
std::wstring fFilename;
|
||||||
char **fLines;
|
char** fLines;
|
||||||
uint32_t *fColors;
|
uint32_t* fColors;
|
||||||
hsMutex fMutex; // To make multithreaded-safe
|
hsSemaphore* fSema;
|
||||||
FILE* fFileHandle;
|
FILE* fFileHandle;
|
||||||
uint32_t fSize;
|
uint32_t fSize;
|
||||||
bool fEncryptMe;
|
bool fEncryptMe;
|
||||||
bool fForceLog;
|
bool fForceLog;
|
||||||
|
|
||||||
plStatusLog *fNext, **fBack;
|
plStatusLog *fNext, **fBack;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user