Skip to content

Commit

Permalink
chore: replace scheduleDirect with Completable
Browse files Browse the repository at this point in the history
  • Loading branch information
pollend committed Jun 29, 2021
1 parent 11a257a commit 23b174e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.rendering.opengl;

import io.reactivex.rxjava3.core.Completable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.config.Config;
Expand Down Expand Up @@ -102,10 +103,10 @@ public void saveScreenshot() {
int height = sceneFinalFbo.height();

if (savingGamePreview) {
GameThread.io().scheduleDirect(() -> saveGamePreviewTask(buffer, width, height));
Completable.fromRunnable(() -> saveGamePreviewTask(buffer, width, height)).subscribeOn(GameThread.io()).subscribe();
this.savingGamePreview = false;
} else {
GameThread.io().scheduleDirect(() -> saveScreenshotTask(buffer, width, height));
Completable.fromRunnable(() -> saveScreenshotTask(buffer, width, height)).subscribeOn(GameThread.io()).subscribe();
}

isTakingScreenshot = false;
Expand Down
13 changes: 5 additions & 8 deletions facades/PC/src/main/java/org/terasology/engine/Terasology.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Scheduler;
import io.reactivex.rxjava3.functions.Action;
import io.reactivex.rxjava3.schedulers.Schedulers;
import io.reactivex.rxjava3.core.Completable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.crashreporter.CrashReporter;
Expand Down Expand Up @@ -157,16 +154,16 @@ public static void main(String[] args) {
engine.run(new StateHeadlessSetup());
} else if (loadLastGame) {
engine.initialize(); //initialize the managers first
GameThread.io().scheduleDirect(() -> {
Completable.fromRunnable(() -> {
GameManifest gameManifest = getLatestGameManifest();
if (gameManifest != null) {
engine.changeState(new StateLoading(gameManifest, NetworkMode.NONE));
}
});
}).subscribeOn(GameThread.io()).subscribe();
} else {
if (createLastGame) {
engine.initialize();
GameThread.io().scheduleDirect(() -> {
Completable.fromRunnable(() -> {
GameManifest gameManifest = getLatestGameManifest();
if (gameManifest != null) {
String title = gameManifest.getTitle();
Expand All @@ -177,7 +174,7 @@ public static void main(String[] args) {
}
engine.changeState(new StateLoading(gameManifest, NetworkMode.NONE));
}
});
}).subscribeOn(GameThread.io()).subscribe();
}

engine.run(new StateMainMenu());
Expand Down

0 comments on commit 23b174e

Please sign in to comment.