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:
parent
3249d81654
commit
3c3596dbf2
14 changed files with 7 additions and 107 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
// Takes ownership of backend.
|
||||
RetryingFileLoader::RetryingFileLoader(FileLoader *backend)
|
||||
: filepos_(0), backend_(backend) {
|
||||
: backend_(backend) {
|
||||
}
|
||||
|
||||
RetryingFileLoader::~RetryingFileLoader() {
|
||||
|
@ -60,10 +60,6 @@ std::string RetryingFileLoader::Path() const {
|
|||
return backend_->Path();
|
||||
}
|
||||
|
||||
void RetryingFileLoader::Seek(s64 absolutePos) {
|
||||
filepos_ = absolutePos;
|
||||
}
|
||||
|
||||
size_t RetryingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Flags flags) {
|
||||
size_t readSize = backend_->ReadAt(absolutePos, bytes, data, flags);
|
||||
|
||||
|
@ -74,6 +70,5 @@ size_t RetryingFileLoader::ReadAt(s64 absolutePos, size_t bytes, void *data, Fla
|
|||
++retries;
|
||||
}
|
||||
|
||||
filepos_ = absolutePos + readSize;
|
||||
return readSize;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue