mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Kotlinify LinearCountingRetryPolicy (#43871)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43871 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: alanleedev Differential Revision: D55753695 fbshipit-source-id: 4a46b02b2dd18981968371a94d2fa07af90fc74e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7cffdf2d73
commit
efb00077ae
@@ -2899,7 +2899,7 @@ public abstract interface class com/facebook/react/jstasks/HeadlessJsTaskRetryPo
|
||||
public abstract fun update ()Lcom/facebook/react/jstasks/HeadlessJsTaskRetryPolicy;
|
||||
}
|
||||
|
||||
public class com/facebook/react/jstasks/LinearCountingRetryPolicy : com/facebook/react/jstasks/HeadlessJsTaskRetryPolicy {
|
||||
public final class com/facebook/react/jstasks/LinearCountingRetryPolicy : com/facebook/react/jstasks/HeadlessJsTaskRetryPolicy {
|
||||
public fun <init> (II)V
|
||||
public fun canRetry ()Z
|
||||
public fun copy ()Lcom/facebook/react/jstasks/HeadlessJsTaskRetryPolicy;
|
||||
|
||||
-48
@@ -1,48 +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.jstasks;
|
||||
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public class LinearCountingRetryPolicy implements HeadlessJsTaskRetryPolicy {
|
||||
|
||||
private final int mRetryAttempts;
|
||||
private final int mDelayBetweenAttemptsInMs;
|
||||
|
||||
public LinearCountingRetryPolicy(int retryAttempts, int delayBetweenAttemptsInMs) {
|
||||
mRetryAttempts = retryAttempts;
|
||||
mDelayBetweenAttemptsInMs = delayBetweenAttemptsInMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRetry() {
|
||||
return mRetryAttempts > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDelay() {
|
||||
return mDelayBetweenAttemptsInMs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeadlessJsTaskRetryPolicy update() {
|
||||
final int remainingRetryAttempts = mRetryAttempts - 1;
|
||||
|
||||
if (remainingRetryAttempts > 0) {
|
||||
return new LinearCountingRetryPolicy(remainingRetryAttempts, mDelayBetweenAttemptsInMs);
|
||||
} else {
|
||||
return NoRetryPolicy.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeadlessJsTaskRetryPolicy copy() {
|
||||
return new LinearCountingRetryPolicy(mRetryAttempts, mDelayBetweenAttemptsInMs);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.jstasks
|
||||
|
||||
public class LinearCountingRetryPolicy(
|
||||
private val retryAttempts: Int,
|
||||
private val delayBetweenAttemptsInMs: Int
|
||||
) : HeadlessJsTaskRetryPolicy {
|
||||
|
||||
override public fun canRetry(): Boolean = retryAttempts > 0
|
||||
|
||||
override public fun getDelay(): Int = delayBetweenAttemptsInMs
|
||||
|
||||
override public fun update(): HeadlessJsTaskRetryPolicy {
|
||||
val remainingRetryAttempts = retryAttempts - 1
|
||||
|
||||
return if (remainingRetryAttempts > 0) {
|
||||
LinearCountingRetryPolicy(remainingRetryAttempts, delayBetweenAttemptsInMs)
|
||||
} else {
|
||||
NoRetryPolicy.INSTANCE
|
||||
}
|
||||
}
|
||||
|
||||
override public fun copy(): HeadlessJsTaskRetryPolicy =
|
||||
LinearCountingRetryPolicy(retryAttempts, delayBetweenAttemptsInMs)
|
||||
}
|
||||
Reference in New Issue
Block a user