16
16
import java .util .concurrent .TimeUnit ;
17
17
18
18
import io .reactivex .annotations .Experimental ;
19
+ import io .reactivex .annotations .NonNull ;
19
20
import io .reactivex .disposables .Disposable ;
20
21
import io .reactivex .exceptions .Exceptions ;
21
22
import io .reactivex .functions .Function ;
@@ -61,6 +62,7 @@ public static long clockDriftTolerance() {
61
62
*
62
63
* @return a Worker representing a serial queue of actions to be executed
63
64
*/
65
+ @ NonNull
64
66
public abstract Worker createWorker ();
65
67
66
68
/**
@@ -69,7 +71,7 @@ public static long clockDriftTolerance() {
69
71
* @return the 'current time'
70
72
* @since 2.0
71
73
*/
72
- public long now (TimeUnit unit ) {
74
+ public long now (@ NonNull TimeUnit unit ) {
73
75
return unit .convert (System .currentTimeMillis (), TimeUnit .MILLISECONDS );
74
76
}
75
77
@@ -105,7 +107,8 @@ public void shutdown() {
105
107
* @return the Disposable instance that let's one cancel this particular task.
106
108
* @since 2.0
107
109
*/
108
- public Disposable scheduleDirect (Runnable run ) {
110
+ @ NonNull
111
+ public Disposable scheduleDirect (@ NonNull Runnable run ) {
109
112
return scheduleDirect (run , 0L , TimeUnit .NANOSECONDS );
110
113
}
111
114
@@ -122,7 +125,8 @@ public Disposable scheduleDirect(Runnable run) {
122
125
* @return the Disposable that let's one cancel this particular delayed task.
123
126
* @since 2.0
124
127
*/
125
- public Disposable scheduleDirect (Runnable run , long delay , TimeUnit unit ) {
128
+ @ NonNull
129
+ public Disposable scheduleDirect (@ NonNull Runnable run , long delay , @ NonNull TimeUnit unit ) {
126
130
final Worker w = createWorker ();
127
131
128
132
final Runnable decoratedRun = RxJavaPlugins .onSchedule (run );
@@ -159,7 +163,8 @@ public void run() {
159
163
* @return the Disposable that let's one cancel this particular delayed task.
160
164
* @since 2.0
161
165
*/
162
- public Disposable schedulePeriodicallyDirect (Runnable run , long initialDelay , long period , TimeUnit unit ) {
166
+ @ NonNull
167
+ public Disposable schedulePeriodicallyDirect (@ NonNull Runnable run , long initialDelay , long period , @ NonNull TimeUnit unit ) {
163
168
final Worker w = createWorker ();
164
169
165
170
final Runnable decoratedRun = RxJavaPlugins .onSchedule (run );
@@ -249,7 +254,8 @@ public Disposable schedulePeriodicallyDirect(Runnable run, long initialDelay, lo
249
254
*/
250
255
@ SuppressWarnings ("unchecked" )
251
256
@ Experimental
252
- public <S extends Scheduler & Disposable > S when (Function <Flowable <Flowable <Completable >>, Completable > combine ) {
257
+ @ NonNull
258
+ public <S extends Scheduler & Disposable > S when (@ NonNull Function <Flowable <Flowable <Completable >>, Completable > combine ) {
253
259
return (S ) new SchedulerWhen (combine , this );
254
260
}
255
261
@@ -268,7 +274,8 @@ public abstract static class Worker implements Disposable {
268
274
* Runnable to schedule
269
275
* @return a Disposable to be able to unsubscribe the action (cancel it if not executed)
270
276
*/
271
- public Disposable schedule (Runnable run ) {
277
+ @ NonNull
278
+ public Disposable schedule (@ NonNull Runnable run ) {
272
279
return schedule (run , 0L , TimeUnit .NANOSECONDS );
273
280
}
274
281
@@ -287,7 +294,8 @@ public Disposable schedule(Runnable run) {
287
294
* the time unit of {@code delayTime}
288
295
* @return a Disposable to be able to unsubscribe the action (cancel it if not executed)
289
296
*/
290
- public abstract Disposable schedule (Runnable run , long delay , TimeUnit unit );
297
+ @ NonNull
298
+ public abstract Disposable schedule (@ NonNull Runnable run , long delay , @ NonNull TimeUnit unit );
291
299
292
300
/**
293
301
* Schedules a cancelable action to be executed periodically. This default implementation schedules
@@ -309,7 +317,8 @@ public Disposable schedule(Runnable run) {
309
317
* the time unit of {@code period}
310
318
* @return a Disposable to be able to unsubscribe the action (cancel it if not executed)
311
319
*/
312
- public Disposable schedulePeriodically (Runnable run , final long initialDelay , final long period , final TimeUnit unit ) {
320
+ @ NonNull
321
+ public Disposable schedulePeriodically (@ NonNull Runnable run , final long initialDelay , final long period , @ NonNull final TimeUnit unit ) {
313
322
final SequentialDisposable first = new SequentialDisposable ();
314
323
315
324
final SequentialDisposable sd = new SequentialDisposable (first );
@@ -337,7 +346,7 @@ public Disposable schedulePeriodically(Runnable run, final long initialDelay, fi
337
346
* @return the 'current time'
338
347
* @since 2.0
339
348
*/
340
- public long now (TimeUnit unit ) {
349
+ public long now (@ NonNull TimeUnit unit ) {
341
350
return unit .convert (System .currentTimeMillis (), TimeUnit .MILLISECONDS );
342
351
}
343
352
@@ -346,15 +355,17 @@ public long now(TimeUnit unit) {
346
355
* of this task has to happen (accounting for clock drifts).
347
356
*/
348
357
final class PeriodicTask implements Runnable {
358
+ @ NonNull
349
359
final Runnable decoratedRun ;
360
+ @ NonNull
350
361
final SequentialDisposable sd ;
351
362
final long periodInNanoseconds ;
352
363
long count ;
353
364
long lastNowNanoseconds ;
354
365
long startInNanoseconds ;
355
366
356
- PeriodicTask (long firstStartInNanoseconds , Runnable decoratedRun ,
357
- long firstNowNanoseconds , SequentialDisposable sd , long periodInNanoseconds ) {
367
+ PeriodicTask (long firstStartInNanoseconds , @ NonNull Runnable decoratedRun ,
368
+ long firstNowNanoseconds , @ NonNull SequentialDisposable sd , long periodInNanoseconds ) {
358
369
this .decoratedRun = decoratedRun ;
359
370
this .sd = sd ;
360
371
this .periodInNanoseconds = periodInNanoseconds ;
@@ -395,12 +406,12 @@ public void run() {
395
406
static class PeriodicDirectTask
396
407
implements Runnable , Disposable {
397
408
final Runnable run ;
398
-
409
+ @ NonNull
399
410
final Worker worker ;
400
-
411
+ @ NonNull
401
412
volatile boolean disposed ;
402
413
403
- PeriodicDirectTask (Runnable run , Worker worker ) {
414
+ PeriodicDirectTask (@ NonNull Runnable run , @ NonNull Worker worker ) {
404
415
this .run = run ;
405
416
this .worker = worker ;
406
417
}
0 commit comments