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:
Nika Layzell 2021-10-18 19:34:59 +00:00
Родитель db97a652b6
Коммит 40de6947f1
2 изменённых файлов: 16 добавлений и 10 удалений

Просмотреть файл

@ -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;