mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 23:40:29 +02:00
Make threading lock-free
The core and the headless tools no longer use mutexes, condition variables, spinlocks, std::atomic, std::thread or volatile flags. Threads hand off through libretro-common's retro_atomic and rthreads plus a few small pieces on top of them in Common/Thread: Thread, MpscQueue, EventCounter, ParkingLot waits and ReaderGate. Every wait blocks until it's woken; nothing polls on a timer. State that only one thread touches just loses its lock. The PSP filesystem, sceIo and the savedata dialog now belong to the emulation thread: async reads and writes run when they're queued and complete later in emulated time, and the IO and savedata threads are gone. The friend finder only talks to the adhoc server and hands what it gets to the emulation thread. GPU init always runs on the thread that starts the game. The Vulkan render and compile queues, pipeline and render pass caches, delete list and SPIR-V cache, the GL render queue, the software renderer's jit caches, the file loader caches, the web debugger, UPnP, input, savestates, logging and the GE debugger all hand off through queues and atomics. The IR jit's spinning profiler thread goes. A CPU thread with nothing to run now sleeps until work is queued instead of spinning. Headless with --debugger waits for a client while stopped, and ends the run once every client that connected has left. Web server shutdown keeps servicing the CPU queue until the server has finished.
This commit is contained in:
1 parent
f0b97a2e90
commit
f1208a7a5a
211 files changed
+5465
-5625
No files matched your search
@@ -20,11 +20,12 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
#include "Core/FileSystems/FileSystem.h"
|
||||
|
||||
// The emulation thread's view of the PSP devices. Not thread safe: everything that touches it runs
|
||||
// on the emulation thread (sceIo, the utility dialogs, savestates, boot).
|
||||
class MetaFileSystem : public IHandleAllocator, public IFileSystem {
|
||||
private:
|
||||
s32 current;
|
||||
@@ -47,13 +48,11 @@ private:
|
||||
std::map<int, std::string> currentDir;
|
||||
|
||||
std::string startingDirectory;
|
||||
mutable std::recursive_mutex lock; // must be recursive. TODO: fix that
|
||||
|
||||
// For the UMD host0 hack.
|
||||
bool host0Mapped_ = false;
|
||||
|
||||
// Assumes the lock is held
|
||||
void Reset() {
|
||||
void Reset() {
|
||||
// This used to be 6, probably an attempt to replicate PSP handles.
|
||||
// However, that's an artifact of using psplink anyway...
|
||||
current = 1;
|
||||
@@ -147,7 +146,6 @@ public:
|
||||
int ReadEntireFile(const std::string &filename, std::vector<u8> &data, bool quiet = false);
|
||||
|
||||
void SetStartingDirectory(std::string_view dir) {
|
||||
std::lock_guard<std::recursive_mutex> guard(lock);
|
||||
startingDirectory = dir;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user