37
37
import com .diffplug .common .primitives .Ints ;
38
38
import com .diffplug .common .rx .*;
39
39
import com .diffplug .common .util .concurrent .ListenableFuture ;
40
+ import com .diffplug .common .util .concurrent .MoreExecutors ;
40
41
import edu .umd .cs .findbugs .annotations .SuppressFBWarnings ;
41
42
42
43
/**
65
66
* In the rare scenario where you need higher performance, it is possible to get similar behavior as {@link #immediate()} but with
66
67
* less overhead (and safety) in {@link #swtOnly()} and {@link SwtExec#sameThread()}. It is very rarely worth this sacrifice.
67
68
*/
68
- public class SwtExec extends AbstractExecutorService implements ScheduledExecutorService , Rx . HasRxExecutor {
69
+ public class SwtExec extends AbstractExecutorService implements ScheduledExecutorService , RxExecutor . Has {
69
70
private static Display display ;
70
71
private static Thread swtThread ;
71
72
@@ -269,17 +270,17 @@ private Runnable guardedRunnable(Runnable toGuard) {
269
270
}
270
271
271
272
@ Override
272
- public <T > Subscription subscribe (Observable <? extends T > observable , Rx <T > listener ) {
273
+ public <T > Subscription subscribe (Observable <? extends T > observable , RxListener <T > listener ) {
273
274
return subscribe (() -> parent .rxExecutor .subscribe (observable , listener ));
274
275
}
275
276
276
277
@ Override
277
- public <T > Subscription subscribe (ListenableFuture <? extends T > future , Rx <T > listener ) {
278
+ public <T > Subscription subscribe (ListenableFuture <? extends T > future , RxListener <T > listener ) {
278
279
return subscribe (() -> parent .rxExecutor .subscribe (future , listener ));
279
280
}
280
281
281
282
@ Override
282
- public <T > Subscription subscribe (CompletionStage <? extends T > future , Rx <T > listener ) {
283
+ public <T > Subscription subscribe (CompletionStage <? extends T > future , RxListener <T > listener ) {
283
284
return subscribe (() -> parent .rxExecutor .subscribe (future , listener ));
284
285
}
285
286
@@ -300,19 +301,19 @@ private Subscription subscribe(Supplier<Subscription> subscriber) {
300
301
}
301
302
}
302
303
303
- protected final Rx . RxExecutor rxExecutor ;
304
+ protected final RxExecutor rxExecutor ;
304
305
305
- /** Returns an instance of {@link com.diffplug.common.rx.Rx. RxExecutor}. */
306
+ /** Returns an instance of {@link com.diffplug.common.rx.RxExecutor}. */
306
307
@ Override
307
- public Rx . RxExecutor getRxExecutor () {
308
+ public RxExecutor getRxExecutor () {
308
309
return rxExecutor ;
309
310
}
310
311
311
312
SwtExec () {
312
- this (exec -> Rx .on (exec , new SwtScheduler (exec )));
313
+ this (exec -> Rx .callbackOn (exec , new SwtScheduler (exec )));
313
314
}
314
315
315
- SwtExec (Function <SwtExec , Rx . RxExecutor > rxExecutorCreator ) {
316
+ SwtExec (Function <SwtExec , RxExecutor > rxExecutorCreator ) {
316
317
initSwtThreads ();
317
318
this .rxExecutor = rxExecutorCreator .apply (this );
318
319
}
@@ -821,7 +822,7 @@ void cancel() {
821
822
@ SuppressFBWarnings (value = "LI_LAZY_INIT_STATIC" , justification = "This race condition is fine, see comment in SwtExec.blocking()" )
822
823
public static SwtExec swtOnly () {
823
824
if (swtOnly == null ) {
824
- swtOnly = new SwtExec (exec -> Rx .on (exec , new SwtOnlyScheduler ())) {
825
+ swtOnly = new SwtExec (exec -> Rx .callbackOn (exec , new SwtOnlyScheduler ())) {
825
826
@ Override
826
827
public void execute (Runnable runnable ) {
827
828
requireNonNull (runnable );
@@ -884,7 +885,7 @@ public boolean isUnsubscribed() {
884
885
}
885
886
}
886
887
887
- private static final SwtExec sameThread = new SwtExec (exec -> Rx .on ( exec , Schedulers .immediate ())) {
888
+ private static final SwtExec sameThread = new SwtExec (exec -> Rx .callbackOn ( MoreExecutors . directExecutor () , Schedulers .immediate ())) {
888
889
@ Override
889
890
public void execute (Runnable runnable ) {
890
891
requireNonNull (runnable );
0 commit comments