fix task part

This commit is contained in:
Tungstend 2022-10-19 23:02:35 +08:00
parent d32baadf27
commit bc2e74fea9
5 changed files with 18 additions and 8 deletions

View File

@ -24,6 +24,7 @@ import java.util.logging.Level;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
// Todo : fix
public final class GameVersion {
private GameVersion() {
}

View File

@ -13,6 +13,7 @@ import java.util.stream.Stream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
// Todo : fix
public class World {
private final Path file;

View File

@ -1,8 +1,11 @@
package com.tungsten.fclcore.task;
import static com.tungsten.fclcore.task.CompletableFutureTask.resolveException;
import static com.tungsten.fclcore.util.Lang.rethrow;
import static com.tungsten.fclcore.util.Lang.wrap;
import com.google.gson.JsonParseException;
import com.tungsten.fclcore.util.Lang;
import com.tungsten.fclcore.util.Logging;
import java.util.Collection;

View File

@ -2,6 +2,8 @@ package com.tungsten.fclcore.task;
import static com.tungsten.fclcore.util.Lang.threadPool;
import android.app.Activity;
import com.tungsten.fclcore.util.Logging;
import java.util.concurrent.*;
@ -34,6 +36,10 @@ public final class Schedulers {
return IO_EXECUTOR;
}
public static Executor androidUIThread(Activity activity) {
return activity::runOnUiThread;
}
public static Executor defaultScheduler() {
return ForkJoinPool.commonPool();
}

View File

@ -17,6 +17,7 @@ import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.logging.Level;
import java.util.stream.Collectors;
/**
* Disposable task.
@ -311,11 +312,11 @@ public abstract class Task<T> {
}
protected void updateProgressImmediately(double progress) {
// Todo : update progress
}
protected final void updateMessage(String newMessage) {
// Todo : update msg
}
public final T run() throws Exception {
@ -895,11 +896,7 @@ public abstract class Task<T> {
@Override
public void execute() {
List<Object> result = new ArrayList<>();
for (Task<?> task : tasks) {
result.add(task.getResult());
}
setResult(result);
setResult(tasks.stream().map(Task::getResult).collect(Collectors.toList()));
}
@Override
@ -968,7 +965,7 @@ public abstract class Task<T> {
}
private static String getCaller() {
return ReflectionHelper.getCaller("com.tungsten.fclcore.task").toString();
return ReflectionHelper.getCaller(packageName -> !"org.jackhuang.hmcl.task".equals(packageName)).toString();
}
private static final class SimpleTask<T> extends Task<T> {
@ -1005,6 +1002,8 @@ public abstract class Task<T> {
/**
* A task that combines two tasks and make sure [pred] runs before succ.
*
* @author huangyuhui
*/
private final class UniCompose<U> extends Task<U> {