Backed out changeset 9d8b4c0b99ed (bug 1945683) for causing btime failures. CLOSED...
[gecko.git] / js / public / HelperThreadAPI.h
blob36f6a341c60168bb79da531f8c1872909f69b20f
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /*
8 * API for supplying an external thread pool to run internal work off the main
9 * thread.
12 #ifndef js_HelperThreadAPI_h
13 #define js_HelperThreadAPI_h
15 #include <stddef.h> // size_t
17 #include "jstypes.h" // JS_PUBLIC_API
19 namespace JS {
21 class HelperThreadTask;
23 /**
24 * Set callback to dispatch a task to an external thread pool.
26 * When the task runs it should call JS::RunHelperThreadTask passing |task|.
28 using HelperThreadTaskCallback = void (*)(HelperThreadTask* task);
29 extern JS_PUBLIC_API void SetHelperThreadTaskCallback(
30 HelperThreadTaskCallback callback, size_t threadCount, size_t stackSize);
32 // Function to call from external thread pool to run a helper thread task.
33 extern JS_PUBLIC_API void RunHelperThreadTask(HelperThreadTask* task);
35 // Function to get the name of the helper thread task.
36 extern JS_PUBLIC_API const char* GetHelperThreadTaskName(
37 HelperThreadTask* task);
39 } // namespace JS
41 #endif // js_HelperThreadAPI_h