-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebWorkers: New c++ interface for NativeRunnable
Reviewed By: mhorowitz, lexs Differential Revision: D2779083 fb-gh-sync-id: dc36b71504b4e74b1671bb48f72d001c9c87721b
- Loading branch information
Showing
4 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
ReactAndroid/src/main/java/com/facebook/react/bridge/queue/NativeRunnableDeprecated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
package com.facebook.react.bridge.queue; | ||
|
||
import com.facebook.jni.Countable; | ||
import com.facebook.jni.HybridData; | ||
import com.facebook.proguard.annotations.DoNotStrip; | ||
|
||
/** | ||
* A Runnable that has a native run implementation. | ||
*/ | ||
@DoNotStrip | ||
public class NativeRunnableDeprecated extends Countable implements Runnable { | ||
|
||
@DoNotStrip | ||
private NativeRunnableDeprecated() { | ||
} | ||
|
||
public native void run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
|
||
#include <jni.h> | ||
|
||
using namespace facebook::jni; | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class Runnable : public JavaClass<Runnable> { | ||
public: | ||
static constexpr auto kJavaDescriptor = "Ljava/lang/Runnable;"; | ||
}; | ||
|
||
/** | ||
* The c++ interface for the Java NativeRunnable class | ||
*/ | ||
class JNativeRunnable : public HybridClass<JNativeRunnable, Runnable> { | ||
public: | ||
static auto constexpr kJavaDescriptor = "Lcom/facebook/react/bridge/queue/NativeRunnable;"; | ||
|
||
void run() { | ||
m_runnable(); | ||
} | ||
|
||
static void registerNatives() { | ||
javaClassStatic()->registerNatives({ | ||
makeNativeMethod("run", JNativeRunnable::run), | ||
}); | ||
} | ||
private: | ||
friend HybridBase; | ||
|
||
JNativeRunnable(std::function<void()> runnable) | ||
: m_runnable(std::move(runnable)) {} | ||
|
||
std::function<void()> m_runnable; | ||
}; | ||
|
||
} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters