Skip to content

Commit

Permalink
Replace NativeRunnable with fbjni implementation (#33776)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
javache authored and facebook-github-bot committed May 9, 2022
1 parent 883a938 commit 80f7367
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 96 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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());
};
Expand Down
1 change: 0 additions & 1 deletion ReactAndroid/src/main/jni/react/jni/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ EXPORTED_HEADERS = [
"JavaScriptExecutorHolder.h",
"JCallback.h",
"JMessageQueueThread.h",
"JNativeRunnable.h",
"JReactMarker.h",
"JSLoader.h",
"JSLogging.h",
Expand Down
3 changes: 0 additions & 3 deletions ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <logger/react_native_log.h>

#include "CxxModuleWrapper.h"
#include "JNativeRunnable.h"
#include "JReactCxxErrorHandler.h"
#include "JReactSoftExceptionLogger.h"
#include "JavaScriptExecutorHolder.h"
Expand Down Expand Up @@ -155,8 +154,6 @@ void CatalystInstanceImpl::registerNatives() {
"warnOnLegacyNativeModuleSystemUse",
CatalystInstanceImpl::warnOnLegacyNativeModuleSystemUse),
});

JNativeRunnable::registerNatives();
}

void log(ReactNativeLogLevel level, const char *message) {
Expand Down
12 changes: 5 additions & 7 deletions ReactAndroid/src/main/jni/react/jni/JMessageQueueThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
#include <mutex>

#include <fb/log.h>
#include <fbjni/NativeRunnable.h>
#include <fbjni/fbjni.h>
#include <jsi/jsi.h>

#include "JNativeRunnable.h"

namespace facebook {
namespace react {

Expand Down Expand Up @@ -69,11 +68,10 @@ void JMessageQueueThread::runOnQueue(std::function<void()> &&runnable) {
jni::ThreadScope guard;
static auto method =
JavaMessageQueueThread::javaClassStatic()
->getMethod<jboolean(Runnable::javaobject)>("runOnQueue");
method(
m_jobj,
JNativeRunnable::newObjectCxxArgs(wrapRunnable(std::move(runnable)))
.get());
->getMethod<jboolean(JRunnable::javaobject)>("runOnQueue");
auto jrunnable =
JNativeRunnable::newObjectCxxArgs(wrapRunnable(std::move(runnable)));
method(m_jobj, jrunnable.get());
}

void JMessageQueueThread::runOnQueueSync(std::function<void()> &&runnable) {
Expand Down
52 changes: 0 additions & 52 deletions ReactAndroid/src/main/jni/react/jni/JNativeRunnable.h

This file was deleted.

0 comments on commit 80f7367

Please sign in to comment.