How can you call an emitter callback from separate c++ thread in an addon?
问题 For context, I started with this question. I need to call the callback for the emitter in another thread. I made a minimal example but it segfaults on emit.Call({cb, result}); My first instinct is that I have a problem with the lifetimes of env or the emit function. addon.cpp #include <napi.h> #include <iostream> #include <thread> #include <memory> #include <functional> #include <chrono> std::shared_ptr<std::thread> thread; bool running = true; void generate(Napi::Env& env, Napi::Function&