mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Replace NativeRunnable with fbjni implementation (#33776)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33776 The implementations of these modules is pretty much identical, and we're already shipping the fbjni version of this anyway. Changelog: [Internal] Reviewed By: mhorowitz Differential Revision: D36200330 fbshipit-source-id: 135ee621e1e4c5eb9616ce7f442fc6d4b946f865
This commit is contained in:
committed by
Facebook GitHub Bot
parent
883a93871c
commit
80f7367149
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.bridge.queue;
|
||||
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
/** A Runnable that has a native run implementation. */
|
||||
@DoNotStrip
|
||||
public class NativeRunnable implements Runnable {
|
||||
|
||||
private final HybridData mHybridData;
|
||||
|
||||
@DoNotStrip
|
||||
private NativeRunnable(HybridData hybridData) {
|
||||
mHybridData = hybridData;
|
||||
}
|
||||
|
||||
public native void run();
|
||||
}
|
||||
@@ -5,26 +5,22 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/jni/JNativeRunnable.h>
|
||||
|
||||
#include "JBackgroundExecutor.h"
|
||||
|
||||
#include <fbjni/NativeRunnable.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
||||
using facebook::react::JNativeRunnable;
|
||||
using facebook::react::Runnable;
|
||||
|
||||
BackgroundExecutor JBackgroundExecutor::create(const std::string &name) {
|
||||
auto instance = make_global(newInstance(name));
|
||||
return [instance = std::move(instance)](std::function<void()> &&runnable) {
|
||||
static auto method =
|
||||
javaClassStatic()->getMethod<void(Runnable::javaobject)>(
|
||||
javaClassStatic()->getMethod<void(JRunnable::javaobject)>(
|
||||
"queueRunnable");
|
||||
|
||||
auto jrunnable = JNativeRunnable::newObjectCxxArgs(std::move(runnable));
|
||||
method(instance, jrunnable.get());
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user