1
1
package com .anchorfree .bolts ;
2
2
3
+ import android .support .annotation .NonNull ;
3
4
import java .util .Locale ;
4
5
import java .util .concurrent .Executor ;
5
6
import java .util .concurrent .ExecutorService ;
@@ -21,9 +22,9 @@ private static boolean isAndroidRuntime() {
21
22
return javaRuntimeName .toLowerCase (Locale .US ).contains ("android" );
22
23
}
23
24
24
- private final ExecutorService background ;
25
+ @ NonNull private final ExecutorService background ;
25
26
private final ScheduledExecutorService scheduled ;
26
- private final Executor immediate ;
27
+ @ NonNull private final Executor immediate ;
27
28
28
29
private BoltsExecutors () {
29
30
background = !isAndroidRuntime ()
@@ -36,6 +37,7 @@ private BoltsExecutors() {
36
37
/**
37
38
* An {@link java.util.concurrent.Executor} that executes tasks in parallel.
38
39
*/
40
+ @ NonNull
39
41
public static ExecutorService background () {
40
42
return INSTANCE .background ;
41
43
}
@@ -49,7 +51,8 @@ public static ExecutorService background() {
49
51
* the stack runs too deep, at which point it will delegate to {@link BoltsExecutors#background}
50
52
* in order to trim the stack.
51
53
*/
52
- /* package */ static Executor immediate () {
54
+ /* package */ @ NonNull
55
+ static Executor immediate () {
53
56
return INSTANCE .immediate ;
54
57
}
55
58
@@ -61,7 +64,7 @@ public static ExecutorService background() {
61
64
*/
62
65
private static class ImmediateExecutor implements Executor {
63
66
private static final int MAX_DEPTH = 15 ;
64
- private ThreadLocal <Integer > executionDepth = new ThreadLocal <>();
67
+ @ NonNull private ThreadLocal <Integer > executionDepth = new ThreadLocal <>();
65
68
66
69
/**
67
70
* Increments the depth.
@@ -98,7 +101,7 @@ private int decrementDepth() {
98
101
}
99
102
100
103
@ Override
101
- public void execute (Runnable command ) {
104
+ public void execute (@ NonNull Runnable command ) {
102
105
int depth = incrementDepth ();
103
106
try {
104
107
if (depth <= MAX_DEPTH ) {
0 commit comments