MCPcopy Create free account
hub / github.com/borndotcom/react-native-godot / runOnGodotThread

Method runOnGodotThread

android/src/main/cpp/GodotModule.cpp:633–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

631}
632
633void GodotModule::runOnGodotThread(std::function<void()> f, bool wait) {
634 if (wait) {
635 std::mutex waitMutex;
636 std::condition_variable waitVar;
637 bool ready = false;
638 std::function<void()> runFunc = [&f, &waitMutex, &waitVar, &ready]() {
639 f();
640 std::unique_lock<std::mutex> lock(waitMutex);
641 ready = true;
642 lock.unlock();
643 waitVar.notify_one();
644 };
645 std::unique_lock<std::mutex> lock(waitMutex);
646 AndroidPlatformData *data = static_cast<AndroidPlatformData *>(_data);
647 data->thread.enqueue(runFunc);
648 waitVar.wait(lock, [&ready] { return ready; });
649 } else {
650 AndroidPlatformData *data = static_cast<AndroidPlatformData *>(_data);
651 data->thread.enqueue(f);
652 }
653}
654
655void GodotModule::iterate() {
656 godot::GodotInstance *instance = nullptr;

Callers

nothing calls this directly

Calls 1

enqueueMethod · 0.80

Tested by

no test coverage detected