File size: 1,307 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.mojang.realmsclient.gui.task;

import com.mojang.logging.LogUtils;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.slf4j.Logger;

@OnlyIn(Dist.CLIENT)
public interface RepeatedDelayStrategy {
    RepeatedDelayStrategy CONSTANT = new RepeatedDelayStrategy() {
        @Override
        public long delayCyclesAfterSuccess() {
            return 1L;
        }

        @Override
        public long delayCyclesAfterFailure() {
            return 1L;
        }
    };

    long delayCyclesAfterSuccess();

    long delayCyclesAfterFailure();

    static RepeatedDelayStrategy exponentialBackoff(final int p_239256_) {
        return new RepeatedDelayStrategy() {
            private static final Logger LOGGER = LogUtils.getLogger();
            private int failureCount;

            @Override
            public long delayCyclesAfterSuccess() {
                this.failureCount = 0;
                return 1L;
            }

            @Override
            public long delayCyclesAfterFailure() {
                this.failureCount++;
                long i = Math.min(1L << this.failureCount, (long)p_239256_);
                LOGGER.debug("Skipping for {} extra cycles", i);
                return i;
            }
        };
    }
}