Java 类com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener 实例源码

项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
private void incrementPendingJSCalls() {
  int oldPendingCalls = mPendingJSCalls.getAndIncrement();
  boolean wasIdle = oldPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      oldPendingCalls + 1);
  if (wasIdle && !mBridgeIdleListeners.isEmpty()) {
    mNativeModulesQueueThread.runOnQueue(new Runnable() {
      @Override
      public void run() {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeBusy();
        }
      }
    });
  }
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
private void decrementPendingJSCalls() {
  int newPendingCalls = mPendingJSCalls.decrementAndGet();
  // TODO(9604406): handle case of web workers injecting messages to main thread
  //Assertions.assertCondition(newPendingCalls >= 0);
  boolean isNowIdle = newPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      newPendingCalls);

  if (isNowIdle && !mBridgeIdleListeners.isEmpty()) {
    mNativeModulesQueueThread.runOnQueue(new Runnable() {
      @Override
      public void run() {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeIdle();
        }
      }
    });
  }
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
private void incrementPendingJSCalls() {
  int oldPendingCalls = mPendingJSCalls.getAndIncrement();
  boolean wasIdle = oldPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      oldPendingCalls + 1);
  if (wasIdle && !mBridgeIdleListeners.isEmpty()) {
    mNativeModulesQueueThread.runOnQueue(new Runnable() {
      @Override
      public void run() {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeBusy();
        }
      }
    });
  }
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
private void decrementPendingJSCalls() {
  int newPendingCalls = mPendingJSCalls.decrementAndGet();
  // TODO(9604406): handle case of web workers injecting messages to main thread
  //Assertions.assertCondition(newPendingCalls >= 0);
  boolean isNowIdle = newPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      newPendingCalls);

  if (isNowIdle && !mBridgeIdleListeners.isEmpty()) {
    mNativeModulesQueueThread.runOnQueue(new Runnable() {
      @Override
      public void run() {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeIdle();
        }
      }
    });
  }
}
项目:Ironman    文件:CatalystInstanceImpl.java   
/**
 * Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration
 * (besides the UI thread) to finish running. Must be called from the UI thread so that we can
 * fully shut down other threads.
 */
@Override
public void destroy() {
  UiThreadUtil.assertOnUiThread();

  if (mDestroyed) {
    return;
  }

  // TODO: tell all APIs to shut down
  mDestroyed = true;
  mHybridData.resetNative();
  mJavaRegistry.notifyCatalystInstanceDestroy();
  boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0);
  if (!wasIdle && !mBridgeIdleListeners.isEmpty()) {
    for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
      listener.onTransitionToBridgeIdle();
    }
  }

  // This is a noop if the listener was not yet registered.
  Systrace.unregisterListener(mTraceListener);
}
项目:Ironman    文件:CatalystInstanceImpl.java   
private void decrementPendingJSCalls() {
  int newPendingCalls = mPendingJSCalls.decrementAndGet();
  // TODO(9604406): handle case of web workers injecting messages to main thread
  //Assertions.assertCondition(newPendingCalls >= 0);
  boolean isNowIdle = newPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      newPendingCalls);

  if (isNowIdle && !mBridgeIdleListeners.isEmpty()) {
    for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
      listener.onTransitionToBridgeIdle();
    }
  }
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
/**
 * Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration
 * (besides the UI thread) to finish running. Must be called from the UI thread so that we can
 * fully shut down other threads.
 */
@Override
public void destroy() {
  UiThreadUtil.assertOnUiThread();

  if (mDestroyed) {
    return;
  }

  // TODO: tell all APIs to shut down
  mDestroyed = true;
  mNativeModulesQueueThread.runOnQueue(new Runnable() {
    @Override
    public void run() {
      mJavaRegistry.notifyJSInstanceDestroy();
      boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0);
      if (!wasIdle && !mBridgeIdleListeners.isEmpty()) {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeIdle();
        }
      }
      mHybridData.resetNative();
    }
  });

  // This is a noop if the listener was not yet registered.
  Systrace.unregisterListener(mTraceListener);
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
/**
 * Destroys this catalyst instance, waiting for any other threads in ReactQueueConfiguration
 * (besides the UI thread) to finish running. Must be called from the UI thread so that we can
 * fully shut down other threads.
 */
@Override
public void destroy() {
  UiThreadUtil.assertOnUiThread();

  if (mDestroyed) {
    return;
  }

  // TODO: tell all APIs to shut down
  mDestroyed = true;
  mNativeModulesQueueThread.runOnQueue(new Runnable() {
    @Override
    public void run() {
      mJavaRegistry.notifyJSInstanceDestroy();
      boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0);
      if (!wasIdle && !mBridgeIdleListeners.isEmpty()) {
        for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
          listener.onTransitionToBridgeIdle();
        }
      }
      mHybridData.resetNative();
    }
  });

  // This is a noop if the listener was not yet registered.
  Systrace.unregisterListener(mTraceListener);
}
项目:ReactNativeSignatureExample    文件:ReactInstanceManagerImpl.java   
ReactInstanceManagerImpl(
    Context applicationContext,
    @Nullable String jsBundleFile,
    @Nullable String jsMainModuleName,
    List<ReactPackage> packages,
    boolean useDeveloperSupport,
    @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
    LifecycleState initialLifecycleState,
    UIImplementationProvider uiImplementationProvider,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
    @Nullable JSCConfig jscConfig) {
  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  setDisplayMetrics(applicationContext);

  mApplicationContext = applicationContext;
  mJSBundleFile = jsBundleFile;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
}
项目:react-native-ibeacon-android    文件:ReactInstanceManagerImpl.java   
ReactInstanceManagerImpl(
    Context applicationContext,
    @Nullable String jsBundleFile,
    @Nullable String jsMainModuleName,
    List<ReactPackage> packages,
    boolean useDeveloperSupport,
    @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
    LifecycleState initialLifecycleState,
    UIImplementationProvider uiImplementationProvider,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
    @Nullable JSCConfig jscConfig) {
  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  setDisplayMetrics(applicationContext);

  mApplicationContext = applicationContext;
  mJSBundleFile = jsBundleFile;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
}
项目:react-native-box-loaders    文件:ReactInstanceManagerImpl.java   
ReactInstanceManagerImpl(
    Context applicationContext,
    @Nullable Activity currentActivity,
    @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
    @Nullable String jsBundleFile,
    @Nullable String jsMainModuleName,
    List<ReactPackage> packages,
    boolean useDeveloperSupport,
    @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
    LifecycleState initialLifecycleState,
    UIImplementationProvider uiImplementationProvider,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
    @Nullable JSCConfig jscConfig) {
  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  setDisplayMetrics(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mJSBundleFile = jsBundleFile;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
}
项目:Ironman    文件:CatalystInstanceImpl.java   
private void incrementPendingJSCalls() {
  int oldPendingCalls = mPendingJSCalls.getAndIncrement();
  boolean wasIdle = oldPendingCalls == 0;
  Systrace.traceCounter(
      Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
      mJsPendingCallsTitleForTrace,
      oldPendingCalls + 1);
  if (wasIdle && !mBridgeIdleListeners.isEmpty()) {
    for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
      listener.onTransitionToBridgeBusy();
    }
  }
}
项目:RNLearn_Project1    文件:ReactInstanceManager.java   
ReactInstanceManager(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModuleName,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  UIImplementationProvider uiImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  JSCConfig jscConfig,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyNativeModulesEnabled,
  boolean lazyViewManagersEnabled,
  boolean useStartupThread) {

  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mBundleLoader = bundleLoader;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport,
      redBoxHandler);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
  mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
  mLazyViewManagersEnabled = lazyViewManagersEnabled;
  mUseStartupThread = useStartupThread;
}
项目:RNLearn_Project1    文件:ReactInstanceManagerBuilder.java   
public ReactInstanceManagerBuilder setBridgeIdleDebugListener(
  NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  return this;
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
/**
 * Removes a NotThreadSafeBridgeIdleDebugListener previously added with
 * {@link #addBridgeIdleDebugListener}
 */
@Override
public void removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
  mBridgeIdleListeners.remove(listener);
}
项目:RNLearn_Project1    文件:ReactInstanceManager.java   
ReactInstanceManager(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModuleName,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  UIImplementationProvider uiImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  JSCConfig jscConfig,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyNativeModulesEnabled,
  boolean lazyViewManagersEnabled,
  boolean useStartupThread) {

  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mBundleLoader = bundleLoader;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport,
      redBoxHandler);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
  mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
  mLazyViewManagersEnabled = lazyViewManagersEnabled;
  mUseStartupThread = useStartupThread;
}
项目:RNLearn_Project1    文件:ReactInstanceManagerBuilder.java   
public ReactInstanceManagerBuilder setBridgeIdleDebugListener(
  NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  return this;
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
/**
 * Removes a NotThreadSafeBridgeIdleDebugListener previously added with
 * {@link #addBridgeIdleDebugListener}
 */
@Override
public void removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
  mBridgeIdleListeners.remove(listener);
}
项目:ReactNativeSignatureExample    文件:ReactInstanceManager.java   
public Builder setBridgeIdleDebugListener(
    NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  return this;
}
项目:react-native-ibeacon-android    文件:ReactInstanceManager.java   
public Builder setBridgeIdleDebugListener(
    NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  return this;
}
项目:react-native-box-loaders    文件:ReactInstanceManager.java   
public Builder setBridgeIdleDebugListener(
    NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  return this;
}
项目:Ironman    文件:ReactInstanceManager.java   
public Builder setBridgeIdleDebugListener(
    NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener) {
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  return this;
}
项目:Ironman    文件:XReactInstanceManagerImpl.java   
XReactInstanceManagerImpl(
  Context applicationContext,
  @Nullable Activity currentActivity,
  @Nullable DefaultHardwareBackBtnHandler defaultHardwareBackBtnHandler,
  @Nullable JSBundleLoader bundleLoader,
  @Nullable String jsMainModuleName,
  List<ReactPackage> packages,
  boolean useDeveloperSupport,
  @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
  LifecycleState initialLifecycleState,
  UIImplementationProvider uiImplementationProvider,
  NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
  JSCConfig jscConfig,
  @Nullable RedBoxHandler redBoxHandler,
  boolean lazyNativeModulesEnabled,
  boolean lazyViewManagersEnabled) {

  initializeSoLoaderIfNecessary(applicationContext);

  // TODO(9577825): remove this
  ApplicationHolder.setApplication((Application) applicationContext.getApplicationContext());
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);

  mApplicationContext = applicationContext;
  mCurrentActivity = currentActivity;
  mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
  mBundleLoader = bundleLoader;
  mJSMainModuleName = jsMainModuleName;
  mPackages = packages;
  mUseDeveloperSupport = useDeveloperSupport;
  mDevSupportManager = DevSupportManagerFactory.create(
      applicationContext,
      mDevInterface,
      mJSMainModuleName,
      useDeveloperSupport,
      redBoxHandler);
  mBridgeIdleDebugListener = bridgeIdleDebugListener;
  mLifecycleState = initialLifecycleState;
  mUIImplementationProvider = uiImplementationProvider;
  mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mJSCConfig = jscConfig;
  mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
  mLazyViewManagersEnabled = lazyViewManagersEnabled;
}
项目:Ironman    文件:CatalystInstanceImpl.java   
/**
 * Removes a NotThreadSafeBridgeIdleDebugListener previously added with
 * {@link #addBridgeIdleDebugListener}
 */
@Override
public void removeBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
  mBridgeIdleListeners.remove(listener);
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
/**
 * Adds a idle listener for this Catalyst instance. The listener will receive notifications
 * whenever the bridge transitions from idle to busy and vice-versa, where the busy state is
 * defined as there being some non-zero number of calls to JS that haven't resolved via a
 * onBatchComplete call. The listener should be purely passive and not affect application logic.
 */
@Override
public void addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
  mBridgeIdleListeners.add(listener);
}
项目:RNLearn_Project1    文件:CatalystInstanceImpl.java   
/**
 * Adds a idle listener for this Catalyst instance. The listener will receive notifications
 * whenever the bridge transitions from idle to busy and vice-versa, where the busy state is
 * defined as there being some non-zero number of calls to JS that haven't resolved via a
 * onBatchComplete call. The listener should be purely passive and not affect application logic.
 */
@Override
public void addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
  mBridgeIdleListeners.add(listener);
}
项目:Ironman    文件:CatalystInstanceImpl.java   
/**
 * Adds a idle listener for this Catalyst instance. The listener will receive notifications
 * whenever the bridge transitions from idle to busy and vice-versa, where the busy state is
 * defined as there being some non-zero number of calls to JS that haven't resolved via a
 * onBatchComplete call. The listener should be purely passive and not affect application logic.
 */
@Override
public void addBridgeIdleDebugListener(NotThreadSafeBridgeIdleDebugListener listener) {
  mBridgeIdleListeners.add(listener);
}