HelperThreadAPI.h (1285B)
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/. */ 6 7 /* 8 * API for supplying an external thread pool to run internal work off the main 9 * thread. 10 */ 11 12 #ifndef js_HelperThreadAPI_h 13 #define js_HelperThreadAPI_h 14 15 #include <stddef.h> // size_t 16 17 #include "jstypes.h" // JS_PUBLIC_API 18 19 namespace JS { 20 21 class HelperThreadTask; 22 23 /** 24 * Set callback to dispatch a task to an external thread pool. 25 * 26 * When the task runs it should call JS::RunHelperThreadTask passing |task|. 27 */ 28 using HelperThreadTaskCallback = void (*)(HelperThreadTask* task); 29 extern JS_PUBLIC_API void SetHelperThreadTaskCallback( 30 HelperThreadTaskCallback callback, size_t threadCount, size_t stackSize); 31 32 // Function to call from external thread pool to run a helper thread task. 33 extern JS_PUBLIC_API void RunHelperThreadTask(HelperThreadTask* task); 34 35 // Function to get the name of the helper thread task. 36 extern JS_PUBLIC_API const char* GetHelperThreadTaskName( 37 HelperThreadTask* task); 38 39 } // namespace JS 40 41 #endif // js_HelperThreadAPI_h