1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Replace hsMutex with std::mutex

This commit is contained in:
2014-04-05 20:45:58 -07:00
parent 964256411e
commit 2947acb2c8
16 changed files with 166 additions and 342 deletions

View File

@ -56,7 +56,7 @@ plStreamSource::plStreamSource()
void plStreamSource::ICleanup()
{
hsTempMutexLock lock(fMutex);
std::lock_guard<std::mutex> lock(fMutex);
// loop through all the file data records, and delete the streams
decltype(fFileData.begin()) curData;
@ -72,7 +72,7 @@ void plStreamSource::ICleanup()
hsStream* plStreamSource::GetFile(const plFileName& filename)
{
hsTempMutexLock lock(fMutex);
std::lock_guard<std::mutex> lock(fMutex);
plFileName sFilename = filename.Normalize('/');
if (fFileData.find(sFilename) == fFileData.end())
@ -112,7 +112,7 @@ std::vector<plFileName> plStreamSource::GetListOfNames(const plFileName& dir, co
{
plFileName sDir = dir.Normalize('/');
hsAssert(ext.CharAt(0) != '.', "Don't add a dot");
hsTempMutexLock lock(fMutex);
std::lock_guard<std::mutex> lock(fMutex);
// loop through all the file data records, and create the list
std::vector<plFileName> retVal;
@ -142,7 +142,7 @@ bool plStreamSource::InsertFile(const plFileName& filename, hsStream* stream)
{
plFileName sFilename = filename.Normalize('/');
hsTempMutexLock lock(fMutex);
std::lock_guard<std::mutex> lock(fMutex);
if (fFileData.find(sFilename) != fFileData.end())
return false; // duplicate entry, return failure

View File

@ -43,8 +43,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define plStreamSource_h_inc
#include <map>
#include <mutex>
#include "hsStream.h"
#include "hsThread.h"
// A class for holding and accessing file streams. The preloader will insert
// files in here once they are loaded. In internal builds, if a requested file
@ -60,7 +60,7 @@ private:
hsStream* fStream; // we own this pointer, so clean it up
};
std::map<plFileName, fileData, plFileName::less_i> fFileData; // key is filename
hsMutex fMutex;
std::mutex fMutex;
uint32_t fServerKey[4];
void ICleanup(); // closes all file pointers and cleans up after itself