mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Kotlinify SingleThreadAsserter (#43768)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43768 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: cortinico Differential Revision: D55636773 fbshipit-source-id: 2f3d1c73a5d3c7d229b854ab73dcf2902a639c3a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fa808b0840
commit
7d60f403f9
@@ -1746,9 +1746,9 @@ public abstract interface class com/facebook/react/common/ShakeDetector$ShakeLis
|
||||
public abstract fun onShake ()V
|
||||
}
|
||||
|
||||
public class com/facebook/react/common/SingleThreadAsserter {
|
||||
public final class com/facebook/react/common/SingleThreadAsserter {
|
||||
public fun <init> ()V
|
||||
public fun assertNow ()V
|
||||
public final fun assertNow ()V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/common/StandardCharsets {
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.common;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
|
||||
/** Simple class for asserting that operations only run on a single thread. */
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public class SingleThreadAsserter {
|
||||
private @Nullable Thread mThread = null;
|
||||
|
||||
public void assertNow() {
|
||||
Thread current = Thread.currentThread();
|
||||
if (mThread == null) {
|
||||
mThread = current;
|
||||
}
|
||||
Assertions.assertCondition(mThread == current);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.common
|
||||
|
||||
import com.facebook.infer.annotation.Assertions
|
||||
|
||||
/** Simple class for asserting that operations only run on a single thread. */
|
||||
public class SingleThreadAsserter {
|
||||
private var thread: Thread? = null
|
||||
|
||||
public fun assertNow() {
|
||||
val currentThread = Thread.currentThread()
|
||||
if (thread == null) {
|
||||
thread = currentThread
|
||||
}
|
||||
Assertions.assertCondition(thread == currentThread)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user