mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-27 00:03:37 +01:00
Make the Loader API thread-safe
Since the majority of the code is using ReadAt API already, map this to a `readp` "syscall" which does not mutate any state about the file descriptor therefore making it fairly safe multi-threading wise. This allows to get rid of read-time mutexes in RamCachedFileLoader and therefore fixes #9803
This commit is contained in:
1 parent
3249d81654
commit
3c3596dbf2
14 files changed
+7
-107
No files matched your search
@@ -41,7 +41,7 @@ std::mutex DiskCachingFileLoader::cachesMutex_;
|
||||
|
||||
// Takes ownership of backend.
|
||||
DiskCachingFileLoader::DiskCachingFileLoader(FileLoader *backend)
|
||||
: prepared_(false), filesize_(0), filepos_(0), backend_(backend), cache_(nullptr) {
|
||||
: prepared_(false), filesize_(0), backend_(backend), cache_(nullptr) {
|
||||
}
|
||||
|
||||
void DiskCachingFileLoader::Prepare() {
|
||||
@@ -88,10 +88,6 @@ std::string DiskCachingFileLoader::Path() const {
|
||||
return backend_->Path();
|
||||
}
|
||||
|
||||
void DiskCachingFileLoader::Seek(s64 absolutePos) {
|
||||
filepos_ = absolutePos;
|
||||
}
|
||||
|
||||
size_t DiskCachingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Flags flags) {
|
||||
Prepare();
|
||||
size_t readSize;
|
||||
@@ -119,7 +115,6 @@ size_t DiskCachingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data,
|
||||
readSize = backend_->ReadAt(absolutePos, bytes, data, flags);
|
||||
}
|
||||
|
||||
filepos_ = absolutePos + readSize;
|
||||
return readSize;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user