Limit calls to SoLoader

Reviewed By: kathryngray

Differential Revision: D5536048

fbshipit-source-id: 525d5a37f41671abd4b56e5a6f4b88e9af9927b8
This commit is contained in:
Pieter De Baets 2017-08-07 09:45:45 -07:00 committed by Facebook Github Bot
parent 16e96a5647
commit 5d79b26011
1 changed files with 7 additions and 2 deletions

View File

@ -12,8 +12,13 @@ package com.facebook.react.bridge;
import com.facebook.soloader.SoLoader;
public class ReactBridge {
private static boolean sDidInit = false;
public static void staticInit() {
// Ideally we'd put this in static and only run it once, but that causes this method to get stripped
SoLoader.loadLibrary("reactnativejni");
// No locking required here, worst case we'll call into SoLoader twice
// which will do its own locking internally
if (!sDidInit) {
SoLoader.loadLibrary("reactnativejni");
sDidInit = true;
}
}
}