-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebWorkers: Add ExecutorToken to route native module calls to/from wo…
…rkers Summary:To support native modules in web workers, native modules need to have an notion of the JS executor/thread that called into them in order to respond via Callback or JS module call to the right executor on the right thread. ExecutorToken is an object that only serves as a token that can be used to identify an executor/message queue thread in the bridge. It doesn't expose any methods. Native modules Callback objects automatically have this ExecutionContext attached -- JSModule calls for modules that support workers will need to supply an appropriate ExecutorToken when retrieving the JSModule implementation from the ReactContext. Reviewed By: mhorowitz Differential Revision: D2965458 fb-gh-sync-id: 6e354d4df8536d40b12d02bd055f6d06b4ca595d shipit-source-id: 6e354d4df8536d40b12d02bd055f6d06b4ca595d
- Loading branch information
Showing
26 changed files
with
614 additions
and
116 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
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
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
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
24 changes: 24 additions & 0 deletions
24
ReactAndroid/src/main/java/com/facebook/react/bridge/ExecutorToken.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,24 @@ | ||
package com.facebook.react.bridge; | ||
|
||
import com.facebook.jni.HybridData; | ||
import com.facebook.proguard.annotations.DoNotStrip; | ||
|
||
/** | ||
* Class corresponding to a JS VM that can call into native modules. In Java, this should | ||
* just be treated as a black box to be used to help the framework route native->JS calls back to | ||
* the proper JS VM. See {@link ReactContext#getJSModule(ExecutorToken, Class)} and | ||
* {@link BaseJavaModule#supportsWebWorkers()}. | ||
* | ||
* Note: If your application doesn't use web workers, it will only have a single ExecutorToken | ||
* per instance of React Native. | ||
*/ | ||
@DoNotStrip | ||
public class ExecutorToken { | ||
|
||
private final HybridData mHybridData; | ||
|
||
@DoNotStrip | ||
private ExecutorToken(HybridData hybridData) { | ||
mHybridData = hybridData; | ||
} | ||
} |
Oops, something went wrong.