(In reply to Nicholas Nethercote [:njn] from comment #1)
Kris, can you give a brief description why we would want to convert these one-off threads to the new API? (E.g. memory usage, code consistency, etc.) Thanks!
Of course! There's a lot of benefits to using a general-purpose thread pool over creating your own threads.
There's a few problems that come up first with spinning up one-off threads that make it more difficult to maintain a clear global threading picture. Handling offthread work on a case-by-case basis means we have a lot of code that does a similar thing in a lot of different ways. Given the need to reduce thread overhead (see Bug 1476432) the idea of simply creating a new thread whenever some offthread job needs to be done is not ideal. Even if the creator of the thread shuts the thread down after they're done, there's still the additional overhead of winding up and spinning down a thread or pool to do a certain task versus creating just one pool at startup which accepts a variety of jobs. Using a general-purpose pool instead benefits our thread overhead by reducing the amount of threads capable of being active at once on a single content process - with the additional benefit of improving the uniformity of general background work.
In the past, we've used the stream transport service as a sort of general-purpose pool for this reason, but this is also not ideal. In these cases the stream transport service is not necessarily used for its intended purpose and it's caused the amount of existing stream transport threads in a content process to be inflated (it's not uncommon in debugging to find myself on the 200+th instance of a stream transport thread, which is not ideal for the same reasons listed above).
Additionally, this API significantly simplifies the process of dispatching background jobs. There's no need to hold a reference to a thread or event target in simple dispatch cases, and when a job requires a background task queue to manipulate, the task queues handle their own shutdown. A simpler API benefits anyone looking to do any work offthread in the future.