-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Scheduler v1->v2 conversion, cleanup v2->v1
- Loading branch information
Showing
27 changed files
with
422 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.11.5 | ||
version=0.12.0 |
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/CompletableV1ToCompletableV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/CompletableV1ToMaybeV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/CompletableV2ToCompletableV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/DisposableV2ToSubscriptionV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/FlowableV2ToObservableV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/MaybeV2ToCompletableV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/MaybeV2ToSingleV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/ObservableV1ToFlowableV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/ObservableV1ToObservableV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/hu/akarnokd/rxjava/interop/ProcessorV2ToSubjectV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
src/main/java/hu/akarnokd/rxjava/interop/SchedulerV1ToSchedulerV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 2016-2018 David Karnok | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package hu.akarnokd.rxjava.interop; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Wraps a 1.x {@link rx.Scheduler} and exposes it as a | ||
* 2.x {@link io.reactivex.Scheduler}. | ||
* @since 0.12.0 | ||
*/ | ||
final class SchedulerV1ToSchedulerV2 extends io.reactivex.Scheduler { | ||
|
||
final rx.Scheduler source; | ||
|
||
SchedulerV1ToSchedulerV2(rx.Scheduler source) { | ||
this.source = source; | ||
} | ||
|
||
@Override | ||
public long now(TimeUnit unit) { | ||
return unit.convert(source.now(), TimeUnit.MILLISECONDS); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
if (source instanceof rx.internal.schedulers.SchedulerLifecycle) { | ||
((rx.internal.schedulers.SchedulerLifecycle)source).start(); | ||
} | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
if (source instanceof rx.internal.schedulers.SchedulerLifecycle) { | ||
((rx.internal.schedulers.SchedulerLifecycle)source).shutdown(); | ||
} | ||
} | ||
|
||
@Override | ||
public Worker createWorker() { | ||
return new WorkerV1ToWorkerV2(source.createWorker()); | ||
} | ||
|
||
static final class WorkerV1ToWorkerV2 extends io.reactivex.Scheduler.Worker { | ||
|
||
final rx.Scheduler.Worker v1Worker; | ||
|
||
WorkerV1ToWorkerV2(rx.Scheduler.Worker v1Worker) { | ||
this.v1Worker = v1Worker; | ||
} | ||
|
||
@Override | ||
public io.reactivex.disposables.Disposable schedule(Runnable action) { | ||
final RunnableToV1Action0 runnable = new RunnableToV1Action0(action); | ||
return RxJavaInterop.toV2Disposable(v1Worker.schedule(runnable)); | ||
} | ||
|
||
@Override | ||
public io.reactivex.disposables.Disposable schedule(Runnable action, long delayTime, TimeUnit unit) { | ||
final RunnableToV1Action0 runnable = new RunnableToV1Action0(action); | ||
return RxJavaInterop.toV2Disposable(v1Worker.schedule(runnable, delayTime, unit)); | ||
} | ||
|
||
@Override | ||
public io.reactivex.disposables.Disposable schedulePeriodically(Runnable action, long initialDelay, long period, TimeUnit unit) { | ||
final RunnableToV1Action0 runnable = new RunnableToV1Action0(action); | ||
return RxJavaInterop.toV2Disposable(v1Worker.schedulePeriodically(runnable, initialDelay, period, unit)); | ||
} | ||
|
||
@Override | ||
public long now(TimeUnit unit) { | ||
return unit.convert(v1Worker.now(), TimeUnit.MILLISECONDS); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
v1Worker.unsubscribe(); | ||
} | ||
|
||
@Override | ||
public boolean isDisposed() { | ||
return v1Worker.isUnsubscribed(); | ||
} | ||
} | ||
|
||
static final class RunnableToV1Action0 implements rx.functions.Action0 { | ||
|
||
final Runnable source; | ||
|
||
RunnableToV1Action0(Runnable source) { | ||
io.reactivex.internal.functions.ObjectHelper.requireNonNull(source, "Source 2.x Runnable is null"); | ||
this.source = source; | ||
} | ||
|
||
@Override | ||
public void call() { | ||
source.run(); | ||
} | ||
} | ||
} |
Oops, something went wrong.