mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 22:58:19 +00:00
Summary: This is only the core C++ part of TurboModule - moving to github to make integration with existing NativeModules system slightly easier. Other bindings for iOS/Android are not yet ready to move. Notes: * TurboModules is not ready to use at the moment. * Build configuration is not yet provided (cocoapods/.xcodeproj/gradle), just like Fabric. * No effort was done to make this lib C++17 strictly compliant yet (there will be in the future). Reviewed By: RSNara Differential Revision: D13551211 fbshipit-source-id: cd3b458e6746ee9218451962ca65b1ad641a32db
39 lines
978 B
C++
39 lines
978 B
C++
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
class MessageQueueThread;
|
|
|
|
/**
|
|
* A generic native-to-JS call invoker. It guarantees that any calls from any
|
|
* thread are queued on the right JS thread.
|
|
*
|
|
* For now, this is a thin-wrapper around existing MessageQueueThread. Eventually,
|
|
* it should be consolidated with Fabric implementation so there's only one
|
|
* API to call JS from native, whether synchronously or asynchronously.
|
|
*/
|
|
class JSCallInvoker {
|
|
public:
|
|
JSCallInvoker(std::shared_ptr<MessageQueueThread> jsThread);
|
|
|
|
void invokeAsync(std::function<void()>&& func);
|
|
void invokeSync(std::function<void()>&& func);
|
|
|
|
private:
|
|
std::shared_ptr<MessageQueueThread> jsThread_;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|