Standardize on just one mutex implementation.

This commit is contained in:
Unknown W. Brackets 2016-03-06 13:30:31 -08:00
parent 955b0fb9db
commit da03b80c97
8 changed files with 42 additions and 40 deletions

View File

@ -187,7 +187,7 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const
if (level > log->GetLevel() || !log->IsEnabled() || !log->HasListeners())
return;
std::lock_guard<std::mutex> lk(log_lock_);
lock_guard lk(log_lock_);
static const char level_to_char[8] = "-NEWIDV";
char formattedTime[13];
Common::Timer::GetTimeFormatted(formattedTime);
@ -266,13 +266,13 @@ LogChannel::LogChannel(const char* shortName, const char* fullName, bool enable)
// LogContainer
void LogChannel::AddListener(LogListener *listener) {
std::lock_guard<std::mutex> lk(m_listeners_lock);
lock_guard lk(m_listeners_lock);
m_listeners.insert(listener);
m_hasListeners = true;
}
void LogChannel::RemoveListener(LogListener *listener) {
std::lock_guard<std::mutex> lk(m_listeners_lock);
lock_guard lk(m_listeners_lock);
m_listeners.erase(listener);
m_hasListeners = !m_listeners.empty();
}
@ -281,7 +281,7 @@ void LogChannel::Trigger(LogTypes::LOG_LEVELS level, const char *msg) {
#ifdef __SYMBIAN32__
RDebug::Printf("%s",msg);
#else
std::lock_guard<std::mutex> lk(m_listeners_lock);
lock_guard lk(m_listeners_lock);
std::set<LogListener*>::const_iterator i;
for (i = m_listeners.begin(); i != m_listeners.end(); ++i) {
@ -303,7 +303,7 @@ void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg) {
if (!IsEnabled() || !IsValid())
return;
std::lock_guard<std::mutex> lk(m_log_lock);
lock_guard lk(m_log_lock);
m_logfile << msg << std::flush;
}

View File

@ -17,13 +17,12 @@
#pragma once
#include <set>
#include "base/mutex.h"
#include "file/ini_file.h"
#include "Log.h"
#include "StringUtils.h"
#include "FileUtil.h"
#include "file/ini_file.h"
#include <set>
#include "StdMutex.h"
#define MAX_MESSAGES 8000
#define MAX_MSGLEN 1024
@ -51,7 +50,7 @@ public:
const char* GetName() const { return "file"; }
private:
std::mutex m_log_lock;
recursive_mutex m_log_lock;
std::ofstream m_logfile;
bool m_enable;
};
@ -113,7 +112,7 @@ public:
private:
char m_fullName[128];
char m_shortName[32];
std::mutex m_listeners_lock;
recursive_mutex m_listeners_lock;
std::set<LogListener*> m_listeners;
bool m_hasListeners;
};
@ -128,7 +127,7 @@ private:
DebuggerLogListener *debuggerLog_;
RingbufferLogListener *ringLog_;
static LogManager *logManager_; // Singleton. Ugh.
std::mutex log_lock_;
recursive_mutex log_lock_;
LogManager();
~LogManager();

View File

@ -20,10 +20,10 @@
#include <cstdio>
#include "base/logging.h"
#include "base/mutex.h"
#include "profiler/profiler.h"
#include "Common/MsgHandler.h"
#include "Common/StdMutex.h"
#include "Common/Atomics.h"
#include "Core/CoreTiming.h"
#include "Core/Core.h"
@ -86,7 +86,7 @@ s64 idledCycles;
s64 lastGlobalTimeTicks;
s64 lastGlobalTimeUs;
static std::recursive_mutex externalEventSection;
static recursive_mutex externalEventSection;
// Warning: not included in save state.
void (*advanceCallback)(int cyclesExecuted) = NULL;
@ -228,7 +228,7 @@ void Shutdown()
delete ev;
}
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
lock_guard lk(externalEventSection);
while(eventTsPool)
{
Event *ev = eventTsPool;
@ -252,7 +252,7 @@ u64 GetIdleTicks()
// schedule things to be executed on the main thread.
void ScheduleEvent_Threadsafe(s64 cyclesIntoFuture, int event_type, u64 userdata)
{
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
lock_guard lk(externalEventSection);
Event *ne = GetNewTsEvent();
ne->time = GetTicks() + cyclesIntoFuture;
ne->type = event_type;
@ -273,7 +273,7 @@ void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata)
{
if(false) //Core::IsCPUThread())
{
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
lock_guard lk(externalEventSection);
event_types[event_type].callback(userdata, 0);
}
else
@ -368,7 +368,7 @@ s64 UnscheduleEvent(int event_type, u64 userdata)
s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata)
{
s64 result = 0;
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
lock_guard lk(externalEventSection);
if (!tsFirst)
return result;
while(tsFirst)
@ -478,7 +478,7 @@ void RemoveEvent(int event_type)
void RemoveThreadsafeEvent(int event_type)
{
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
lock_guard lk(externalEventSection);
if (!tsFirst)
{
return;
@ -552,7 +552,7 @@ void MoveEvents()
{
Common::AtomicStoreRelease(hasTsEvents, 0);
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
lock_guard lk(externalEventSection);
// Move events from async queue into main queue
while (tsFirst)
{
@ -692,7 +692,7 @@ void Event_DoStateOld(PointerWrap &p, BaseEvent *ev)
void DoState(PointerWrap &p)
{
std::lock_guard<std::recursive_mutex> lk(externalEventSection);
lock_guard lk(externalEventSection);
auto s = p.Section("CoreTiming", 1, 3);
if (!s)

View File

@ -17,6 +17,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <math.h>
#include "base/mutex.h"
#include "Globals.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/FunctionWrappers.h"
@ -24,7 +25,6 @@
#include "Core/CoreTiming.h"
#include "Core/MemMapHelpers.h"
#include "Common/ChunkFile.h"
#include "Common/StdMutex.h"
#include "Core/HLE/sceCtrl.h"
#include "Core/HLE/sceDisplay.h"
#include "Core/HLE/sceKernel.h"
@ -84,7 +84,7 @@ static int ctrlIdleBack = -1;
static int ctrlCycle = 0;
static std::vector<SceUID> waitingThreads;
static std::recursive_mutex ctrlMutex;
static recursive_mutex ctrlMutex;
static int ctrlTimer = -1;
@ -101,7 +101,7 @@ const u32 CTRL_EMU_RAPIDFIRE_MASK = CTRL_UP | CTRL_DOWN | CTRL_LEFT | CTRL_RIGHT
static void __CtrlUpdateLatch()
{
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
// Copy in the current data to the current buffer.
ctrlBufs[ctrlBuf] = ctrlCurrent;
@ -144,14 +144,14 @@ static int __CtrlResetLatch()
u32 __CtrlPeekButtons()
{
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
return ctrlCurrent.buttons;
}
void __CtrlPeekAnalog(int stick, float *x, float *y)
{
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
*x = (ctrlCurrent.analog[stick][CTRL_ANALOG_X] - 127.5f) / 127.5f;
*y = -(ctrlCurrent.analog[stick][CTRL_ANALOG_Y] - 127.5f) / 127.5f;
@ -170,27 +170,27 @@ u32 __CtrlReadLatch()
void __CtrlButtonDown(u32 buttonBit)
{
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
ctrlCurrent.buttons |= buttonBit;
}
void __CtrlButtonUp(u32 buttonBit)
{
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
ctrlCurrent.buttons &= ~buttonBit;
}
void __CtrlSetAnalogX(float x, int stick)
{
u8 scaled = clamp_u8((int)ceilf(x * 127.5f + 127.5f));
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
ctrlCurrent.analog[stick][CTRL_ANALOG_X] = scaled;
}
void __CtrlSetAnalogY(float y, int stick)
{
u8 scaled = clamp_u8((int)ceilf(-y * 127.5f + 127.5f));
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
ctrlCurrent.analog[stick][CTRL_ANALOG_Y] = scaled;
}
@ -304,7 +304,7 @@ void __CtrlInit()
ctrlIdleBack = -1;
ctrlCycle = 0;
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
ctrlBuf = 1;
ctrlBufRead = 0;
@ -326,7 +326,7 @@ void __CtrlInit()
void __CtrlDoState(PointerWrap &p)
{
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
lock_guard guard(ctrlMutex);
auto s = p.Section("sceCtrl", 1, 3);
if (!s)

View File

@ -15,13 +15,14 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <algorithm>
#include <vector>
#include "base/mutex.h"
#include "base/timeutil.h"
#include "base/NativeApp.h"
#include "i18n/i18n.h"
#include "Common/StdMutex.h"
#include "Common/FileUtil.h"
#include "Common/ChunkFile.h"
@ -206,7 +207,7 @@ namespace SaveState
static bool needsProcess = false;
static std::vector<Operation> pending;
static std::recursive_mutex mutex;
static recursive_mutex mutex;
static bool hasLoadedState = false;
// TODO: Should this be configurable?
@ -250,7 +251,7 @@ namespace SaveState
void Enqueue(SaveState::Operation op)
{
std::lock_guard<std::recursive_mutex> guard(mutex);
lock_guard guard(mutex);
pending.push_back(op);
// Don't actually run it until next frame.
@ -486,7 +487,7 @@ namespace SaveState
std::vector<Operation> Flush()
{
std::lock_guard<std::recursive_mutex> guard(mutex);
lock_guard guard(mutex);
std::vector<Operation> copy = pending;
pending.clear();
@ -670,7 +671,7 @@ namespace SaveState
// Make sure there's a directory for save slots
pspFileSystem.MkDir("ms0:/PSP/PPSSPP_STATE");
std::lock_guard<std::recursive_mutex> guard(mutex);
lock_guard guard(mutex);
rewindStates.Clear();
hasLoadedState = false;

View File

@ -55,7 +55,7 @@ restart:
void OnScreenMessages::Show(const std::string &text, float duration_s, uint32_t color, int icon, bool checkUnique, const char *id) {
double now = time_now_d();
std::lock_guard<std::recursive_mutex> guard(mutex_);
lock_guard guard(mutex_);
if (checkUnique) {
for (auto iter = messages_.begin(); iter != messages_.end(); ++iter) {
if (iter->text == text || (id && iter->id && !strcmp(iter->id, id))) {

View File

@ -3,9 +3,9 @@
#include <string>
#include <list>
#include "base/mutex.h"
#include "base/basictypes.h"
#include "math/geom2d.h"
#include "Common/StdMutex.h"
#include "ui/view.h"
@ -39,7 +39,7 @@ public:
private:
std::list<Message> messages_;
std::recursive_mutex mutex_;
recursive_mutex mutex_;
};
class OnScreenMessagesView : public UI::InertView {

View File

@ -19,6 +19,8 @@
#undef p
#undef DrawText
#undef itoa
#undef min
#undef max
#else
#include <pthread.h>