Skip to content

Commit

Permalink
[SH]StackExecutor: noop on Wasm without threads
Browse files Browse the repository at this point in the history
When targeting a threadless Wasm environment, StackExecutor cannot rely
on creating another thread, so make it just call the function directly,
which is better than failing.
  • Loading branch information
tmikov committed Dec 23, 2024
1 parent 037d022 commit 559b19b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/Support/StackExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ void executeInStack(StackExecutor &exec, void *arg, void (*func)(void *arg)) {

} // namespace hermes

#elif defined(__wasm__) && !defined(__EMSCRIPTEN_THREADS__)
namespace hermes {

#pragma message("Warning: StackExecutor is no-op in Wasm without threads!")

class StackExecutor {
public:
};

std::shared_ptr<StackExecutor> newStackExecutor(
size_t stackSize,
std::chrono::milliseconds) {
return std::make_shared<StackExecutor>();
}

void executeInStack(StackExecutor &exec, void *arg, void (*func)(void *arg)) {
func(arg);
}

} // namespace hermes

#else

#include "hermes/Support/SerialExecutor.h"
Expand Down

0 comments on commit 559b19b

Please sign in to comment.