Files
nitro/packages/react-native-nitro-modules/cpp/platform/ThreadUtils.hpp
T
Marc RousavyandGitHub 992e32e09e feat: Automatically install a UI-Thread Dispatcher (#1192)
* feat: Automatically install a UI-Thread Dispatcher if called on the UI Thread

* fix: Avoid runSync on UI

* Update UIThreadDispatcher.hpp
2026-02-01 17:31:40 +01:00

45 lines
845 B
C++

//
// ThreadUtils.hpp
// react-native-nitro
//
// Created by Marc Rousavy on 14.07.24.
//
#pragma once
#include "Dispatcher.hpp"
#include <memory>
#include <string>
namespace margelo::nitro {
class ThreadUtils final {
public:
ThreadUtils() = delete;
/**
* Get the current Thread's name.
* This is implemented differently on iOS and Android.
*/
static std::string getThreadName();
/**
* Set the current Thread's name.
* This is implemented differently on iOS and Android.
*/
static void setThreadName(const std::string& name);
/**
* Gets whether the caller is currently running
* on the Main/UI Thread.
*/
static bool isUIThread();
/**
* Create a `Dispatcher` for the Main/UI Thread.
*/
static std::shared_ptr<Dispatcher> createUIThreadDispatcher();
};
} // namespace margelo::nitro