Open
Description
➜ src emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.34 (57b21b8fdcbe3ebb523178b79465254668eab408)
clang version 17.0.0 (https://github.com/llvm/llvm-project a031f72187ce495b9faa4ccf99b1e901a3872f4b)
In my app I use a main thread:
std::thread main_loop = std::thread(&Document::MainLoop, this);
In this thread I wait for a conditional variable:
std::unique_lock<std::recursive_mutex> lock(tasks_mutex);
if (tasks.empty() && undos.empty() && redos.empty())
{
printf("Wait on conditional\n");
if (next_circle.wait_for(lock, caret_settings.blink_delay * 1ms) == std::cv_status::timeout) //wait for tasks
{
caret->Blink();
continue;
}
}
Somewhere in the code I notify it:
next_circle.notify_one();
So, in the Linux app it works fine. In the webasm app it works so:
- Waiting on "next_circle.wait_for()" is infinite every time.
- Code "next_circle.notify_one()" passes about 4 times, after it hangs forever. I tried to debug it, the debugger shows waiting in the conditional variable's mutex... But who is the second thread who locks it I can't find.
My question is: how should I work with conditional variables? What's wrong with this code? Are C++ conditional variables supported in emscripten?