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/. */
8 * API for supplying an external thread pool to run internal work off the main
12 #ifndef js_HelperThreadAPI_h
13 #define js_HelperThreadAPI_h
15 #include <stddef.h> // size_t
17 #include "jstypes.h" // JS_PUBLIC_API
21 class HelperThreadTask
;
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
);
41 #endif // js_HelperThreadAPI_h