mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1734700 - Use the IO event queue for IOUtils background tasks, r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D128311
This commit is contained in:
parent
db97a652b6
commit
40de6947f1
@ -1597,14 +1597,20 @@ template <typename OkT, typename Fn>
|
||||
RefPtr<IOUtils::IOPromise<OkT>> IOUtils::EventQueue::Dispatch(Fn aFunc) {
|
||||
MOZ_RELEASE_ASSERT(mBackgroundEventTarget);
|
||||
|
||||
return InvokeAsync(
|
||||
mBackgroundEventTarget, __func__, [func = std::move(aFunc)]() {
|
||||
Result<OkT, IOError> result = func();
|
||||
if (result.isErr()) {
|
||||
return IOPromise<OkT>::CreateAndReject(result.unwrapErr(), __func__);
|
||||
}
|
||||
return IOPromise<OkT>::CreateAndResolve(result.unwrap(), __func__);
|
||||
});
|
||||
auto promise =
|
||||
MakeRefPtr<typename IOUtils::IOPromise<OkT>::Private>(__func__);
|
||||
mBackgroundEventTarget->Dispatch(
|
||||
NS_NewRunnableFunction("IOUtils::EventQueue::Dispatch",
|
||||
[promise, func = std::move(aFunc)] {
|
||||
Result<OkT, IOError> result = func();
|
||||
if (result.isErr()) {
|
||||
promise->Reject(result.unwrapErr(), __func__);
|
||||
} else {
|
||||
promise->Resolve(result.unwrap(), __func__);
|
||||
}
|
||||
}),
|
||||
NS_DISPATCH_EVENT_MAY_BLOCK);
|
||||
return promise;
|
||||
};
|
||||
|
||||
Result<already_AddRefed<nsIAsyncShutdownClient>, nsresult>
|
||||
|
@ -14,7 +14,7 @@ add_task(async () => {
|
||||
const filename = "test_marker_fileio";
|
||||
const profile = await startProfilerAndTriggerFileIO({
|
||||
features: ["fileioall"],
|
||||
threadsFilter: ["GeckoMain", "BackgroundThreadPool"],
|
||||
threadsFilter: ["GeckoMain", "BgIOThreadPool"],
|
||||
filename,
|
||||
});
|
||||
|
||||
@ -25,7 +25,7 @@ add_task(async () => {
|
||||
let backgroundThreadFileIO;
|
||||
for (const thread of threads) {
|
||||
// Check for FileIO in any of the background threads.
|
||||
if (thread.name.startsWith("BackgroundThreadPool")) {
|
||||
if (thread.name.startsWith("BgIOThreadPool")) {
|
||||
const markers = getInflatedFileIOMarkers(thread, filename);
|
||||
if (markers.length > 0) {
|
||||
backgroundThread = thread;
|
||||
|
Loading…
Reference in New Issue
Block a user