Skip to content

Commit bb8a5df

Browse files
authored
Adapt threadpool for WASM/Emscripten compatibility
Differential Revision: D94744811 Pull Request resolved: #18106
1 parent cdac43c commit bb8a5df

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

extension/threadpool/targets.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def define_common_targets():
5050
"ovr_config//os:windows": [":threadpool_lib"],
5151
"ovr_config//os:android": [":threadpool_lib"],
5252
"ovr_config//os:iphoneos": [":threadpool_lib"],
53+
"ovr_config//runtime:wasm-emscripten": [":threadpool_lib"],
5354
# Machines without an operating system shouldn't.
5455
"ovr_config//os:none": ["//executorch/runtime/kernel:thread_parallel_interface"],
5556
# If we don't know what it is, disable threadpool out of caution.

extension/threadpool/threadpool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
namespace executorch::extension::threadpool {
3838

39-
#if !(defined(WIN32))
39+
#if !defined(WIN32) && !defined(__EMSCRIPTEN__)
4040
namespace {
4141
// After fork, the child process inherits the data-structures of the parent
4242
// process' thread-pool, but since those threads don't exist, the thread-pool
@@ -153,7 +153,7 @@ ThreadPool* get_threadpool() {
153153

154154
// Inheriting from old threadpool to get around segfault issue
155155
// commented above at child_atfork
156-
#if !(defined(WIN32))
156+
#if !defined(WIN32) && !defined(__EMSCRIPTEN__)
157157
// @lint-ignore CLANGTIDY facebook-hte-std::once_flag
158158
static std::once_flag flag;
159159
// @lint-ignore CLANGTIDY facebook-hte-std::call_once

0 commit comments

Comments
 (0)