Ver código fonte

WebDavMounter warmUp in background thread.

Sebastian Stenzel 10 anos atrás
pai
commit
028f6ea824

+ 2 - 5
main/ui/src/main/java/org/cryptomator/ui/util/FXThreads.java

@@ -63,14 +63,12 @@ public final class FXThreads {
 	 * 	myLabel.setText(bookName);
 	 * });
 	 * </pre>
+	 * 
 	 * @param executor
 	 * @param task The task to wait for.
 	 * @param successCallback The action to perform, when the task finished.
 	 */
 	public static <T> void runOnMainThreadWhenFinished(ExecutorService executor, Future<T> task, CallbackWhenTaskFinished<T> successCallback) {
-		executor.submit(() -> {
-			return "asd";
-		});
 		runOnMainThreadWhenFinished(executor, task, successCallback, DUMMY_EXCEPTION_CALLBACK);
 	}
 
@@ -89,8 +87,7 @@ public final class FXThreads {
 	 * });
 	 * </pre>
 	 * 
-	 * @param executor
-	 *            The service to execute the background task on
+	 * @param executor The service to execute the background task on
 	 * @param task The task to wait for.
 	 * @param successCallback The action to perform, when the task finished.
 	 * @param exceptionCallback

+ 6 - 2
main/ui/src/main/java/org/cryptomator/ui/util/mount/WebDavMounterProvider.java

@@ -9,6 +9,8 @@
  ******************************************************************************/
 package org.cryptomator.ui.util.mount;
 
+import java.util.concurrent.ExecutorService;
+
 import javax.inject.Inject;
 
 import org.cryptomator.webdav.WebDavServer;
@@ -24,9 +26,11 @@ public class WebDavMounterProvider implements Provider<WebDavMounter> {
 	private final WebDavMounterStrategy choosenStrategy;
 
 	@Inject
-	public WebDavMounterProvider(WebDavServer server) {
+	public WebDavMounterProvider(WebDavServer server, ExecutorService executorService) {
 		this.choosenStrategy = getStrategyWhichShouldWork();
-		this.choosenStrategy.warmUp(server.getPort());
+		executorService.execute(() -> {
+			this.choosenStrategy.warmUp(server.getPort());
+		});
 	}
 
 	@Override