mirror of https://github.com/PCSX2/pcsx2.git
Misc: Replace use of Threading::Mutex with std::mutex in core code
This commit is contained in:
parent
a93829557b
commit
65e956a01c
|
@ -16,7 +16,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include "common/Threading.h"
|
||||
#include <mutex>
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// EventSource< template EvtType >
|
||||
|
@ -41,7 +41,7 @@ protected:
|
|||
ListenerList m_cache_copy;
|
||||
bool m_cache_valid;
|
||||
|
||||
Threading::Mutex m_listeners_lock;
|
||||
std::mutex m_listeners_lock;
|
||||
|
||||
public:
|
||||
EventSource()
|
||||
|
|
|
@ -14,15 +14,14 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/Threading.h"
|
||||
|
||||
using Threading::ScopedLock;
|
||||
#include "common/Pcsx2Defs.h"
|
||||
#include "common/Exceptions.h"
|
||||
#include "common/Console.h"
|
||||
|
||||
template <typename ListenerType>
|
||||
typename EventSource<ListenerType>::ListenerIterator EventSource<ListenerType>::Add(ListenerType& listener)
|
||||
{
|
||||
ScopedLock locker(m_listeners_lock);
|
||||
std::unique_lock locker(m_listeners_lock);
|
||||
|
||||
// Check for duplicates before adding the event.
|
||||
if (IsDebugBuild)
|
||||
|
@ -41,7 +40,7 @@ typename EventSource<ListenerType>::ListenerIterator EventSource<ListenerType>::
|
|||
template <typename ListenerType>
|
||||
void EventSource<ListenerType>::Remove(ListenerType& listener)
|
||||
{
|
||||
ScopedLock locker(m_listeners_lock);
|
||||
std::unique_lock locker(m_listeners_lock);
|
||||
m_cache_valid = false;
|
||||
m_listeners.remove(&listener);
|
||||
}
|
||||
|
@ -49,7 +48,7 @@ void EventSource<ListenerType>::Remove(ListenerType& listener)
|
|||
template <typename ListenerType>
|
||||
void EventSource<ListenerType>::Remove(const ListenerIterator& listenerHandle)
|
||||
{
|
||||
ScopedLock locker(m_listeners_lock);
|
||||
std::unique_lock locker(m_listeners_lock);
|
||||
m_cache_valid = false;
|
||||
m_listeners.erase(listenerHandle);
|
||||
}
|
||||
|
|
|
@ -14,13 +14,15 @@
|
|||
*/
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <wx/thread.h>
|
||||
#include <sys/mman.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common/PageFaultSource.h"
|
||||
#include "common/Console.h"
|
||||
#include "common/Exceptions.h"
|
||||
#include "common/StringHelpers.h"
|
||||
|
||||
// Apple uses the MAP_ANON define instead of MAP_ANONYMOUS, but they mean
|
||||
// the same thing.
|
||||
|
@ -55,7 +57,7 @@ static void SysPageFaultSignalFilter(int signal, siginfo_t* siginfo, void*)
|
|||
// Note: This signal can be accessed by the EE or MTVU thread
|
||||
// Source_PageFault is a global variable with its own state information
|
||||
// so for now we lock this exception code unless someone can fix this better...
|
||||
Threading::ScopedLock lock(PageFault_Mutex);
|
||||
std::unique_lock lock(PageFault_Mutex);
|
||||
|
||||
Source_PageFault->Dispatch(PageFaultInfo((uptr)siginfo->si_addr & ~m_pagemask));
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
|
||||
#include "EventSource.h"
|
||||
#include "General.h"
|
||||
#include "Assertions.h"
|
||||
#include "Dependencies.h"
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
struct PageFaultInfo
|
||||
{
|
||||
|
@ -314,6 +317,5 @@ extern long __stdcall SysPageFaultExceptionFilter(struct _EXCEPTION_POINTERS* ep
|
|||
extern void pxInstallSignalHandler();
|
||||
extern void _platform_InstallSignalHandler();
|
||||
|
||||
#include "Threading.h"
|
||||
extern SrcType_PageFault* Source_PageFault;
|
||||
extern Threading::Mutex PageFault_Mutex;
|
||||
extern std::mutex PageFault_Mutex;
|
||||
|
|
|
@ -13,17 +13,15 @@
|
|||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __WXMSW__
|
||||
#include <wx/thread.h>
|
||||
#endif
|
||||
#include "common/PageFaultSource.h"
|
||||
#include "common/EventSource.inl"
|
||||
#include "common/MemsetFast.inl"
|
||||
#include "common/Console.h"
|
||||
|
||||
template class EventSource<IEventListener_PageFault>;
|
||||
|
||||
SrcType_PageFault* Source_PageFault = NULL;
|
||||
Threading::Mutex PageFault_Mutex;
|
||||
std::mutex PageFault_Mutex;
|
||||
|
||||
void pxInstallSignalHandler()
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "common/Vulkan/Builders.h"
|
||||
#include "common/Vulkan/Util.h"
|
||||
#include "common/Assertions.h"
|
||||
#include <limits>
|
||||
|
||||
namespace Vulkan
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "common/RedtapeWindows.h"
|
||||
#include "common/PageFaultSource.h"
|
||||
#include "common/Console.h"
|
||||
|
||||
static long DoSysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps)
|
||||
{
|
||||
|
@ -26,7 +27,7 @@ static long DoSysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps)
|
|||
// Note: This exception can be accessed by the EE or MTVU thread
|
||||
// Source_PageFault is a global variable with its own state information
|
||||
// so for now we lock this exception code unless someone can fix this better...
|
||||
Threading::ScopedLock lock(PageFault_Mutex);
|
||||
std::unique_lock lock(PageFault_Mutex);
|
||||
Source_PageFault->Dispatch(PageFaultInfo((uptr)eps->ExceptionRecord->ExceptionInformation[1]));
|
||||
return Source_PageFault->WasHandled() ? EXCEPTION_CONTINUE_EXECUTION : EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "GS/GS.h"
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
extern double GetVerticalFrequency();
|
||||
|
@ -333,8 +334,8 @@ public:
|
|||
std::atomic<int> m_QueuedFrameCount;
|
||||
std::atomic<bool> m_VsyncSignalListener;
|
||||
|
||||
Threading::Mutex m_mtx_RingBufferBusy2; // Gets released on semaXGkick waiting...
|
||||
Threading::Mutex m_mtx_WaitGS;
|
||||
std::mutex m_mtx_RingBufferBusy2; // Gets released on semaXGkick waiting...
|
||||
std::mutex m_mtx_WaitGS;
|
||||
Threading::WorkSema m_sem_event;
|
||||
Threading::KernelSemaphore m_sem_OnRingReset;
|
||||
Threading::KernelSemaphore m_sem_Vsync;
|
||||
|
@ -355,7 +356,7 @@ public:
|
|||
uint m_packet_writepos; // index of the data location in the ringbuffer.
|
||||
|
||||
#ifdef RINGBUF_DEBUG_STACK
|
||||
Threading::Mutex m_lock_Stack;
|
||||
std::mutex m_lock_Stack;
|
||||
#endif
|
||||
|
||||
std::thread m_thread;
|
||||
|
|
|
@ -276,7 +276,7 @@ void SysMtgsThread::MainLoop()
|
|||
PacketTagType prevCmd;
|
||||
#endif
|
||||
|
||||
ScopedLock mtvu_lock(m_mtx_RingBufferBusy2);
|
||||
std::unique_lock mtvu_lock(m_mtx_RingBufferBusy2);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
@ -285,14 +285,13 @@ void SysMtgsThread::MainLoop()
|
|||
// is very optimized (only 1 instruction test in most cases), so no point in trying
|
||||
// to avoid it.
|
||||
|
||||
m_mtx_RingBufferBusy2.Release();
|
||||
|
||||
mtvu_lock.unlock();
|
||||
m_sem_event.WaitForWork();
|
||||
mtvu_lock.lock();
|
||||
|
||||
if (!m_open_flag.load(std::memory_order_acquire))
|
||||
break;
|
||||
|
||||
m_mtx_RingBufferBusy2.Acquire();
|
||||
|
||||
// note: m_ReadPos is intentionally not volatile, because it should only
|
||||
// ever be modified by this thread.
|
||||
while (m_ReadPos.load(std::memory_order_relaxed) != m_WritePos.load(std::memory_order_acquire))
|
||||
|
@ -413,10 +412,10 @@ void SysMtgsThread::MainLoop()
|
|||
MTVU_LOG("MTGS - Waiting on semaXGkick!");
|
||||
if (!vu1Thread.semaXGkick.TryWait())
|
||||
{
|
||||
mtvu_lock.Release();
|
||||
mtvu_lock.unlock();
|
||||
// Wait for MTVU to complete vu1 program
|
||||
vu1Thread.semaXGkick.Wait();
|
||||
mtvu_lock.Acquire();
|
||||
mtvu_lock.lock();
|
||||
}
|
||||
Gif_Path& path = gifUnit.gifPath[GIF_PATH_1];
|
||||
GS_Packet gsPack = path.GetGSPacketMTVU(); // Get vu1 program's xgkick packet(s)
|
||||
|
@ -605,7 +604,9 @@ void SysMtgsThread::WaitGS(bool syncRegs, bool weakWait, bool isMTVU)
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
m_mtx_RingBufferBusy2.Wait();
|
||||
// m_mtx_RingBufferBusy2.Wait();
|
||||
m_mtx_RingBufferBusy2.lock();
|
||||
m_mtx_RingBufferBusy2.unlock();
|
||||
if (path.GetPendingGSPackets() != startP1Packs)
|
||||
break;
|
||||
}
|
||||
|
@ -619,7 +620,7 @@ void SysMtgsThread::WaitGS(bool syncRegs, bool weakWait, bool isMTVU)
|
|||
|
||||
if (syncRegs)
|
||||
{
|
||||
ScopedLock lock(m_mtx_WaitGS);
|
||||
std::unique_lock lock(m_mtx_WaitGS);
|
||||
// Completely synchronize GS and MTGS register states.
|
||||
memcpy(RingBuffer.Regs, PS2MEM_GS, sizeof(RingBuffer.Regs));
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "common/StringUtil.h"
|
||||
#endif
|
||||
|
||||
#include <mutex>
|
||||
|
||||
static WavOutFile* _new_WavOutFile(const char* destfile)
|
||||
{
|
||||
return new WavOutFile(destfile, 48000, 16, 2);
|
||||
|
@ -109,13 +111,13 @@ using namespace Threading;
|
|||
bool WavRecordEnabled = false;
|
||||
|
||||
static WavOutFile* m_wavrecord = nullptr;
|
||||
static Mutex WavRecordMutex;
|
||||
static std::mutex WavRecordMutex;
|
||||
|
||||
bool RecordStart(const std::string* filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
ScopedLock lock(WavRecordMutex);
|
||||
std::unique_lock lock(WavRecordMutex);
|
||||
safe_delete(m_wavrecord);
|
||||
if (filename)
|
||||
#ifdef _WIN32
|
||||
|
@ -142,13 +144,13 @@ bool RecordStart(const std::string* filename)
|
|||
void RecordStop()
|
||||
{
|
||||
WavRecordEnabled = false;
|
||||
ScopedLock lock(WavRecordMutex);
|
||||
std::unique_lock lock(WavRecordMutex);
|
||||
safe_delete(m_wavrecord);
|
||||
}
|
||||
|
||||
void RecordWrite(const StereoOut16& sample)
|
||||
{
|
||||
ScopedLock lock(WavRecordMutex);
|
||||
std::unique_lock lock(WavRecordMutex);
|
||||
if (m_wavrecord == nullptr)
|
||||
return;
|
||||
m_wavrecord->write((s16*)&sample, 2);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
using namespace Threading;
|
||||
|
||||
MutexRecursive mtx_SPU2Status;
|
||||
std::recursive_mutex mtx_SPU2Status;
|
||||
|
||||
int SampleRate = 48000;
|
||||
|
||||
|
@ -259,7 +259,7 @@ uptr gsWindowHandle = 0;
|
|||
|
||||
s32 SPU2open()
|
||||
{
|
||||
ScopedLock lock(mtx_SPU2Status);
|
||||
std::unique_lock lock(mtx_SPU2Status);
|
||||
if (IsOpened)
|
||||
return 0;
|
||||
|
||||
|
@ -307,7 +307,7 @@ s32 SPU2open()
|
|||
|
||||
void SPU2close()
|
||||
{
|
||||
ScopedLock lock(mtx_SPU2Status);
|
||||
std::unique_lock lock(mtx_SPU2Status);
|
||||
if (!IsOpened)
|
||||
return;
|
||||
IsOpened = false;
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/Threading.h"
|
||||
#include "SaveState.h"
|
||||
#include "IopCounters.h"
|
||||
#include <mutex>
|
||||
|
||||
extern Threading::MutexRecursive mtx_SPU2Status;
|
||||
extern std::recursive_mutex mtx_SPU2Status;
|
||||
|
||||
enum class PS2Modes
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue