Revert "Use CompletableFuture.runAsync instead of creating new Threads"
This reverts commit 53684668ab
.
This commit is contained in:
parent
93a662ce22
commit
d1764389f0
|
@ -14,7 +14,6 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -463,7 +462,7 @@ public class CamrecApplication extends Application {
|
|||
}
|
||||
|
||||
private void checkForUpdates() {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Thread updateCheck = new Thread(() -> {
|
||||
String url = "https://pastebin.com/raw/mUxtKzyB";
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try (Response response = httpClient.execute(request)) {
|
||||
|
@ -490,6 +489,9 @@ public class CamrecApplication extends Application {
|
|||
LOG.warn("Update check failed: {}", e.getMessage());
|
||||
}
|
||||
});
|
||||
updateCheck.setName("Update Check");
|
||||
updateCheck.setDaemon(true);
|
||||
updateCheck.start();
|
||||
}
|
||||
|
||||
public static Version getVersion() throws IOException {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ctbrec.ui;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -146,7 +145,7 @@ public class PreviewPopupHandler implements EventHandler<MouseEvent> {
|
|||
}
|
||||
|
||||
private void createTimerThread() {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Thread timerThread = new Thread(() -> {
|
||||
while(true) {
|
||||
openCountdown--;
|
||||
if(openCountdown == 0) {
|
||||
|
@ -182,5 +181,9 @@ public class PreviewPopupHandler implements EventHandler<MouseEvent> {
|
|||
}
|
||||
}
|
||||
});
|
||||
timerThread.setDaemon(true);
|
||||
timerThread.setPriority(Thread.MIN_PRIORITY);
|
||||
timerThread.setName("PreviewPopupTimer");
|
||||
timerThread.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.InputStream;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class StreamSourceSelectionDialog {
|
|||
}
|
||||
});
|
||||
selectStreamSource.setOnFailed(e -> onFail.apply(selectStreamSource.getException()));
|
||||
CompletableFuture.runAsync(selectStreamSource);
|
||||
new Thread(selectStreamSource).start();
|
||||
}
|
||||
|
||||
private static class BestStreamSource extends StreamSource {
|
||||
|
|
|
@ -2,7 +2,6 @@ package ctbrec.ui;
|
|||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -79,7 +78,7 @@ public class TipDialog extends TextInputDialog {
|
|||
}
|
||||
}
|
||||
};
|
||||
CompletableFuture.runAsync(task);
|
||||
new Thread(task).start();
|
||||
}
|
||||
|
||||
private void showErrorDialog(Throwable throwable) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package ctbrec.ui;
|
|||
import java.text.DecimalFormat;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -84,6 +83,6 @@ public class TokenLabel extends Label {
|
|||
}
|
||||
}
|
||||
};
|
||||
CompletableFuture.runAsync(task);
|
||||
new Thread(task).start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package ctbrec.ui.action;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -30,7 +29,7 @@ public class CheckModelAccountAction {
|
|||
public void execute() {
|
||||
String buttonText = b.getText();
|
||||
b.setDisable(true);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Runnable checker = (() -> {
|
||||
List<Model> deletedAccounts = new ArrayList<>();
|
||||
try {
|
||||
List<Model> models = recorder.getModels();
|
||||
|
@ -67,5 +66,6 @@ public class CheckModelAccountAction {
|
|||
});
|
||||
}
|
||||
});
|
||||
new Thread(checker).start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package ctbrec.ui.action;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -31,7 +30,7 @@ public class EditNotesAction {
|
|||
|
||||
public void execute() {
|
||||
source.setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> Platform.runLater(() -> {
|
||||
new Thread(() -> Platform.runLater(() -> {
|
||||
String notes = Config.getInstance().getSettings().modelNotes.getOrDefault(model.getUrl(), "");
|
||||
Optional<String> newNotes = Dialogs.showTextInput(source.getScene(), "Model Notes", "Notes for " + model.getName(), notes);
|
||||
newNotes.ifPresent(n -> {
|
||||
|
@ -48,6 +47,6 @@ public class EditNotesAction {
|
|||
});
|
||||
table.refresh();
|
||||
source.setCursor(Cursor.DEFAULT);
|
||||
}));
|
||||
})).start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,11 @@ package ctbrec.ui.action;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import ctbrec.Model;
|
||||
|
@ -12,6 +16,9 @@ import javafx.scene.Node;
|
|||
|
||||
public class ModelMassEditAction {
|
||||
|
||||
static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
|
||||
static ExecutorService threadPool = new ThreadPoolExecutor(2, 10, 10, TimeUnit.MINUTES, queue);
|
||||
|
||||
protected List<? extends Model> models;
|
||||
protected Consumer<Model> action;
|
||||
protected Node source;
|
||||
|
@ -35,7 +42,7 @@ public class ModelMassEditAction {
|
|||
Consumer<Model> cb = Objects.requireNonNull(callback, "Callback is null, call execute() instead");
|
||||
source.setCursor(Cursor.WAIT);
|
||||
for (Model model : models) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
threadPool.submit(() -> {
|
||||
action.accept(model);
|
||||
cb.accept(model);
|
||||
Platform.runLater(() -> source.setCursor(Cursor.DEFAULT));
|
||||
|
|
|
@ -2,7 +2,6 @@ package ctbrec.ui.action;
|
|||
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
|
@ -27,7 +26,7 @@ public class OpenRecordingsDir {
|
|||
File fileForRecording = Config.getInstance().getFileForRecording(selectedModel, ".mp4", Instant.now());
|
||||
final File dir = getModelDirectory(fileForRecording);
|
||||
if (dir.exists()) {
|
||||
CompletableFuture.runAsync(() -> DesktopIntegration.open(dir));
|
||||
new Thread(() -> DesktopIntegration.open(dir)).start();
|
||||
} else {
|
||||
Dialogs.showError(source.getScene(), "Directory does not exist", "There are no recordings for this model", null);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ctbrec.ui.action;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
import javafx.application.Platform;
|
||||
|
@ -22,7 +20,7 @@ public class ToggleRecordingAction {
|
|||
|
||||
public void execute() {
|
||||
toggleButton.setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
if (pause) {
|
||||
recorder.pause();
|
||||
|
@ -38,5 +36,7 @@ public class ToggleRecordingAction {
|
|||
Platform.runLater(() -> toggleButton.setCursor(Cursor.DEFAULT));
|
||||
}
|
||||
});
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,6 @@ package ctbrec.ui.controls;
|
|||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -168,7 +167,7 @@ public class SearchPopoverTreeList extends PopoverTreeList<Model> implements Pop
|
|||
follow = new Button("Follow");
|
||||
follow.setOnAction(evt -> {
|
||||
setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(new Task<Boolean>() {
|
||||
new Thread(new Task<Boolean>() {
|
||||
@Override
|
||||
protected Boolean call() throws Exception {
|
||||
model.getSite().login();
|
||||
|
@ -184,12 +183,12 @@ public class SearchPopoverTreeList extends PopoverTreeList<Model> implements Pop
|
|||
}
|
||||
Platform.runLater(() -> setCursor(Cursor.DEFAULT));
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
});
|
||||
record = new Button("Record");
|
||||
record.setOnAction(evt -> {
|
||||
setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(new Task<Void>() {
|
||||
new Thread(new Task<Void>() {
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
recorder.startRecording(model);
|
||||
|
@ -200,7 +199,7 @@ public class SearchPopoverTreeList extends PopoverTreeList<Model> implements Pop
|
|||
protected void done() {
|
||||
Platform.runLater(() -> setCursor(Cursor.DEFAULT));
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
});
|
||||
getChildren().addAll(thumb, title, follow, record);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package ctbrec.ui.controls;
|
|||
import java.io.InterruptedIOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -158,14 +157,14 @@ public class StreamPreview extends StackPane {
|
|||
running = false;
|
||||
MediaPlayer old = videoPlayer;
|
||||
Future<?> oldFuture = future;
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
if(oldFuture != null && !oldFuture.isDone()) {
|
||||
oldFuture.cancel(true);
|
||||
}
|
||||
if(old != null) {
|
||||
old.dispose();
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void onError(MediaPlayer videoPlayer) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ctbrec.ui.controls;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
|
@ -38,7 +36,7 @@ public final class Toast {
|
|||
KeyFrame fadeInKey1 = new KeyFrame(Duration.millis(fadeInDelay), new KeyValue(toastStage.getScene().getRoot().opacityProperty(), 1));
|
||||
fadeInTimeline.getKeyFrames().add(fadeInKey1);
|
||||
fadeInTimeline.setOnFinished((ae) -> {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(toastDelay);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -49,7 +47,7 @@ public final class Toast {
|
|||
fadeOutTimeline.getKeyFrames().add(fadeOutKey1);
|
||||
fadeOutTimeline.setOnFinished((aeb) -> toastStage.close());
|
||||
fadeOutTimeline.play();
|
||||
});
|
||||
}).start();
|
||||
});
|
||||
fadeInTimeline.play();
|
||||
}
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
package ctbrec.ui.news;
|
||||
|
||||
import static ctbrec.io.HttpConstants.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.squareup.moshi.JsonAdapter;
|
||||
import com.squareup.moshi.Moshi;
|
||||
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.ui.CamrecApplication;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
|
@ -23,6 +14,12 @@ import javafx.scene.control.Tab;
|
|||
import javafx.scene.layout.VBox;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static ctbrec.io.HttpConstants.USER_AGENT;
|
||||
|
||||
public class NewsTab extends Tab implements TabSelectionListener {
|
||||
private static final String ACCESS_TOKEN = "a2804d73a89951a22e0f8483a6fcec8943afd88b7ba17c459c095aa9e6f94fd0";
|
||||
|
@ -39,7 +36,7 @@ public class NewsTab extends Tab implements TabSelectionListener {
|
|||
|
||||
@Override
|
||||
public void selected() {
|
||||
CompletableFuture.runAsync(this::loadToots);
|
||||
new Thread(this::loadToots).start();
|
||||
}
|
||||
|
||||
private void loadToots() {
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package ctbrec.ui.sites.bonga;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import ctbrec.sites.bonga.BongaCamsHttpClient;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
import ctbrec.ui.sites.AbstractSiteUi;
|
||||
import ctbrec.ui.sites.ConfigUI;
|
||||
import ctbrec.ui.tabs.TabProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
public class BongaCamsSiteUi extends AbstractSiteUi {
|
||||
|
||||
|
@ -46,7 +44,7 @@ public class BongaCamsSiteUi extends AbstractSiteUi {
|
|||
} else {
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
try {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
// login with external browser window
|
||||
try {
|
||||
new BongaCamsElectronLoginDialog(bongaCams.getHttpClient().getCookieJar());
|
||||
|
@ -61,7 +59,7 @@ public class BongaCamsSiteUi extends AbstractSiteUi {
|
|||
Thread.currentThread().interrupt();
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
|
|
@ -13,7 +13,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -137,7 +136,7 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
|
|||
});
|
||||
}
|
||||
};
|
||||
CompletableFuture.runAsync(task);
|
||||
new Thread(task).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,7 +202,7 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
|
|||
|
||||
private void follow(Model model) {
|
||||
setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
SiteUiFactory.getUi(model.getSite()).login();
|
||||
model.follow();
|
||||
|
@ -215,12 +214,12 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
|
|||
setCursor(Cursor.DEFAULT);
|
||||
});
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void record(Model model) {
|
||||
setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
recorder.startRecording(model);
|
||||
} catch (InvalidKeyException | NoSuchAlgorithmException | IllegalStateException | IOException e) {
|
||||
|
@ -230,11 +229,11 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
|
|||
setCursor(Cursor.DEFAULT);
|
||||
});
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void loadImage(Model model, ImageView thumb) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String url = camsoda.getBaseUrl() + "/api/v1/user/" + model.getName();
|
||||
Request detailRequest = new Request.Builder().url(url).build();
|
||||
|
@ -271,7 +270,7 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
|
|||
} catch (Exception e) {
|
||||
LOG.error("Couldn't load model details", e);
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
private Node createLabel(String string, boolean bold) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package ctbrec.ui.sites.jasmin;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -56,7 +55,7 @@ public class LiveJasminSiteUi extends AbstractSiteUi {
|
|||
lastLoginTime = System.currentTimeMillis();
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread (() -> {
|
||||
// login with external browser window
|
||||
try {
|
||||
new LiveJasminElectronLoginDialog(liveJasmin.getHttpClient().getCookieJar());
|
||||
|
@ -70,7 +69,7 @@ public class LiveJasminSiteUi extends AbstractSiteUi {
|
|||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
|
||||
try {
|
||||
queue.take();
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
@ -353,7 +352,7 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
|||
|
||||
if (Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
MenuItem debug = new MenuItem("debug");
|
||||
debug.setOnAction(e -> CompletableFuture.runAsync(() -> {
|
||||
debug.setOnAction(e -> new Thread(() -> {
|
||||
for (Model m : selectedModels) {
|
||||
try {
|
||||
List<StreamSource> sources = m.getStreamSources();
|
||||
|
@ -365,7 +364,7 @@ public class MyFreeCamsTableTab extends Tab implements TabSelectionListener {
|
|||
LOG.error("Couldn't get stream sources", e1);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}).start());
|
||||
menu.getItems().add(debug);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package ctbrec.ui.sites.showup;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -47,7 +46,7 @@ public class ShowupSiteUi extends AbstractSiteUi {
|
|||
} else {
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
try {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
// login with external browser window
|
||||
try {
|
||||
new ShowupElectronLoginDialog(site.getHttpClient().getCookieJar());
|
||||
|
@ -62,7 +61,7 @@ public class ShowupSiteUi extends AbstractSiteUi {
|
|||
LOG.error("Error while signaling termination", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -498,9 +497,9 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
|
||||
private void openContactSheet(JavaFxRecording recording) {
|
||||
if (config.getSettings().localRecording) {
|
||||
recording.getContactSheet().ifPresent(f -> CompletableFuture.runAsync(() -> DesktopIntegration.open(f)));
|
||||
recording.getContactSheet().ifPresent(f -> new Thread(() -> DesktopIntegration.open(f)).start());
|
||||
} else {
|
||||
recording.getContactSheet().ifPresent(f -> CompletableFuture.runAsync(() -> {
|
||||
recording.getContactSheet().ifPresent(f -> new Thread(() -> {
|
||||
File target;
|
||||
try {
|
||||
target = File.createTempFile("cs_", ".jpg");
|
||||
|
@ -518,7 +517,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e) {
|
||||
Dialogs.showError(getTabPane().getScene(), "Download Error", "An error occurred while downloading the contact sheet", e);
|
||||
}
|
||||
}));
|
||||
}).start());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,7 +527,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
Optional<String> newNote = Dialogs.showTextInput(source.getScene(), "Recording Notes", "", notes);
|
||||
if (newNote.isPresent()) {
|
||||
table.setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Thread backgroundThread = new Thread(() -> {
|
||||
List<Exception> exceptions = new ArrayList<>();
|
||||
try {
|
||||
recording.setNote(newNote.get());
|
||||
|
@ -544,12 +543,13 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
});
|
||||
}
|
||||
});
|
||||
backgroundThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void pin(List<JavaFxRecording> recordings) {
|
||||
table.setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Thread backgroundThread = new Thread(() -> {
|
||||
List<Exception> exceptions = new ArrayList<>();
|
||||
try {
|
||||
for (JavaFxRecording javaFxRecording : recordings) {
|
||||
|
@ -570,11 +570,12 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
});
|
||||
}
|
||||
});
|
||||
backgroundThread.start();
|
||||
}
|
||||
|
||||
private void unpin(List<JavaFxRecording> recordings) {
|
||||
table.setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Thread backgroundThread = new Thread(() -> {
|
||||
List<Exception> exceptions = new ArrayList<>();
|
||||
try {
|
||||
for (JavaFxRecording javaFxRecording : recordings) {
|
||||
|
@ -595,6 +596,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
});
|
||||
}
|
||||
});
|
||||
backgroundThread.start();
|
||||
}
|
||||
|
||||
private void jumpToNextModel(KeyCode code) {
|
||||
|
@ -645,11 +647,11 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
|
||||
private void onOpenDirectory(JavaFxRecording first) {
|
||||
File tsFile = first.getAbsoluteFile();
|
||||
CompletableFuture.runAsync(() -> DesktopIntegration.open(tsFile.getParent()));
|
||||
new Thread(() -> DesktopIntegration.open(tsFile.getParent())).start();
|
||||
}
|
||||
|
||||
private void triggerPostProcessing(List<JavaFxRecording> recs) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
for (JavaFxRecording rec : recs) {
|
||||
try {
|
||||
recorder.rerunPostProcessing(rec.getDelegate());
|
||||
|
@ -658,7 +660,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
LOG.error("Error while starting post-processing", e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void download(Recording recording) {
|
||||
|
@ -794,7 +796,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
}
|
||||
|
||||
private void deleteAsync(List<JavaFxRecording> recordings) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
Thread deleteThread = new Thread(() -> {
|
||||
recordingsLock.lock();
|
||||
try {
|
||||
List<Recording> deleted = new ArrayList<>();
|
||||
|
@ -820,6 +822,7 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
|
|||
Platform.runLater(() -> table.setCursor(Cursor.DEFAULT));
|
||||
}
|
||||
});
|
||||
deleteThread.start();
|
||||
}
|
||||
|
||||
public void saveState() {
|
||||
|
|
|
@ -484,7 +484,7 @@ public class ThumbCell extends StackPane {
|
|||
|
||||
void pauseResumeAction(boolean pause) {
|
||||
setCursor(Cursor.WAIT);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
if (pause) {
|
||||
recorder.suspendRecording(model);
|
||||
|
@ -504,11 +504,11 @@ public class ThumbCell extends StackPane {
|
|||
} finally {
|
||||
Platform.runLater(() -> setCursor(Cursor.DEFAULT));
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void startStopActionAsync(Model model, boolean start) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
if (start) {
|
||||
recorder.startRecording(model);
|
||||
|
@ -523,7 +523,7 @@ public class ThumbCell extends StackPane {
|
|||
} finally {
|
||||
Platform.runLater(() -> setCursor(Cursor.DEFAULT));
|
||||
}
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
CompletableFuture<Boolean> follow(boolean follow) {
|
||||
|
|
Loading…
Reference in New Issue