mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:47:36 +00:00
FileSystemAccessServer: Manage concurrent file requests
Before this patch, when you called FileSystemAccessServer::Client::try_* twice, the second call used the same variable to store the promise. This "race condition" is now solved using a HashMap, to store multiple parallel requests.
This commit is contained in:
parent
e432a284d7
commit
9521952f36
6 changed files with 88 additions and 61 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/HashMap.h>
|
||||
#include <FileSystemAccessServer/FileSystemAccessClientEndpoint.h>
|
||||
#include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -41,10 +42,18 @@ private:
|
|||
{
|
||||
}
|
||||
|
||||
virtual void handle_prompt_end(i32 error, Optional<IPC::File> const& fd, Optional<String> const& chosen_file) override;
|
||||
virtual void handle_prompt_end(i32 request_id, i32 error, Optional<IPC::File> const& fd, Optional<String> const& chosen_file) override;
|
||||
|
||||
RefPtr<Core::Promise<Result>> m_promise;
|
||||
GUI::Window* m_parent_window { nullptr };
|
||||
int get_new_id();
|
||||
Result handle_promise(int);
|
||||
|
||||
struct PromiseAndWindow {
|
||||
RefPtr<Core::Promise<Result>> promise {};
|
||||
GUI::Window* parent_window { nullptr };
|
||||
};
|
||||
|
||||
HashMap<int, PromiseAndWindow> m_promises {};
|
||||
int m_last_id { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue