mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Replace hsMutex with std::mutex
This commit is contained in:
@ -90,12 +90,13 @@ hsError plSoundPreloader::Run()
|
||||
|
||||
while (fRunning)
|
||||
{
|
||||
fCritSect.Lock();
|
||||
while (fBuffers.GetCount())
|
||||
{
|
||||
templist.Append(fBuffers.Pop());
|
||||
std::lock_guard<std::mutex> lock(fCritSect);
|
||||
while (fBuffers.GetCount())
|
||||
{
|
||||
templist.Append(fBuffers.Pop());
|
||||
}
|
||||
}
|
||||
fCritSect.Unlock();
|
||||
|
||||
if (templist.GetCount() == 0)
|
||||
{
|
||||
@ -130,14 +131,15 @@ hsError plSoundPreloader::Run()
|
||||
}
|
||||
|
||||
// we need to be sure that all buffers are removed from our load list when shutting this thread down or we will hang,
|
||||
// since the sound buffer will wait to be destroyed until it is marked as loaded
|
||||
fCritSect.Lock();
|
||||
while (fBuffers.GetCount())
|
||||
// since the sound buffer will wait to be destroyed until it is marked as loaded
|
||||
{
|
||||
plSoundBuffer* buf = fBuffers.Pop();
|
||||
buf->SetLoaded(true);
|
||||
std::lock_guard<std::mutex> lock(fCritSect);
|
||||
while (fBuffers.GetCount())
|
||||
{
|
||||
plSoundBuffer* buf = fBuffers.Pop();
|
||||
buf->SetLoaded(true);
|
||||
}
|
||||
}
|
||||
fCritSect.Unlock();
|
||||
|
||||
return hsOK;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plAudioFileReader.h"
|
||||
#include "hsThread.h"
|
||||
#include "plFileSystem.h"
|
||||
#include <mutex>
|
||||
|
||||
//// Class Definition ////////////////////////////////////////////////////////
|
||||
|
||||
@ -165,7 +166,7 @@ protected:
|
||||
hsTArray<plSoundBuffer*> fBuffers;
|
||||
hsEvent fEvent;
|
||||
bool fRunning;
|
||||
hsMutex fCritSect;
|
||||
std::mutex fCritSect;
|
||||
|
||||
public:
|
||||
virtual hsError Run();
|
||||
@ -184,9 +185,10 @@ public:
|
||||
bool IsRunning() const { return fRunning; }
|
||||
|
||||
void AddBuffer(plSoundBuffer* buffer) {
|
||||
fCritSect.Lock();
|
||||
fBuffers.Push(buffer);
|
||||
fCritSect.Unlock();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(fCritSect);
|
||||
fBuffers.Push(buffer);
|
||||
}
|
||||
|
||||
fEvent.Signal();
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -55,7 +55,7 @@ const float TimeBasedAvgRing<T>::kPercision = 0.001;
|
||||
template <class T>
|
||||
void TimeBasedAvgRing<T>::AddItem(T value, double time)
|
||||
{
|
||||
hsTempMutexLock lock( fLock );
|
||||
std::lock_guard<std::mutex> lock(fLock);
|
||||
|
||||
if ( fList.empty() )
|
||||
{
|
||||
|
@ -44,9 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include <list>
|
||||
|
||||
#include "hsThread.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
// A Time based Value Averaging class
|
||||
// implemented in a ring buffer
|
||||
@ -91,7 +89,7 @@ private:
|
||||
float fMaxAvg;
|
||||
double fTotal;
|
||||
TimeListIterator fRingStart, fRingEnd;
|
||||
hsMutex fLock;
|
||||
std::mutex fLock;
|
||||
public:
|
||||
TimeBasedAvgRing():fLen(0.f),fAvg(0.f),fMaxAvg(0.f),fTotal(0.0) {}
|
||||
|
||||
|
@ -69,7 +69,6 @@ class plPipeline;
|
||||
// really be visible at any given time.
|
||||
|
||||
class plStatusLogMgr;
|
||||
class hsMutex;
|
||||
class plStatusLogDrawerStub;
|
||||
class plStatusLog
|
||||
{
|
||||
@ -206,8 +205,6 @@ class plStatusLogMgr
|
||||
|
||||
static plFileName IGetBasePath();
|
||||
|
||||
hsMutex fMutex; // To make multithreaded-safe
|
||||
|
||||
public:
|
||||
|
||||
enum
|
||||
|
Reference in New Issue
Block a user