Snappy/AsyncShutdown

From MozillaWiki
Revision as of 13:09, 23 August 2013 by P.A. (talk | contribs) (→‎Use cases: Add Downloads API)
Jump to navigation Jump to search

Our objective

At the moment, Firefox shuts down mostly sequentially. Waiting until an asynchronous task is complete before proceeding with shutdown is complicated and requires spinning the event loop, which is generally Not a Good Idea.

We need to start thinking about a way to shutdown asynchronous services.

Use cases

Asynchronous databases need to be AsyncClosed()

(TBD)

Telemetry data must be saved asynchronously

(TBD)

Downloads API may have a pending "downloads.json" write

Before saving the list of in-progress downloads, the Downloads API waits 1.5 seconds after every change in state of downloads.

Being able to force an asynchronous write of the JSON file in case the browser is closed during the 1.5 seconds window might be useful.

Related bugs

- https://bugzilla.mozilla.org/show_bug.cgi?id=722648 - Asynchronous observers. - https://bugzilla.mozilla.org/show_bug.cgi?id=881667 - Expose startup/shutdown stage to components.