diff --git a/Tasks/src/main/java/fr/altarik/toolbox/task/async/AsyncTasks.java b/Tasks/src/main/java/fr/altarik/toolbox/task/async/AsyncTasks.java index 29efd5c..8caed53 100644 --- a/Tasks/src/main/java/fr/altarik/toolbox/task/async/AsyncTasks.java +++ b/Tasks/src/main/java/fr/altarik/toolbox/task/async/AsyncTasks.java @@ -1,7 +1,6 @@ package fr.altarik.toolbox.task.async; import fr.altarik.toolbox.task.AltarikRunnable; -import fr.altarik.toolbox.task.TaskI; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -10,7 +9,7 @@ import java.util.concurrent.TimeUnit; /** * A non-blocking small sized time-consuming tasks to executed asynchronously. */ -public class AsyncTasks implements TaskI { +public class AsyncTasks implements AsyncTaskI { private final ExecutorService worker; @@ -30,11 +29,11 @@ public class AsyncTasks implements TaskI { * * @return an instance of AsyncTasks */ - public static TaskI initialize(int numberOfWorker) { + public static AsyncTaskI initialize(int numberOfWorker) { return new AsyncTasks(numberOfWorker); } - public static TaskI initialize() { + public static AsyncTaskI initialize() { return initialize(Runtime.getRuntime().availableProcessors()); } diff --git a/Tasks/src/test/java/fr/altarik/toolbox/AsyncTaskTest.java b/Tasks/src/test/java/fr/altarik/toolbox/task/AsyncTaskTest.java similarity index 82% rename from Tasks/src/test/java/fr/altarik/toolbox/AsyncTaskTest.java rename to Tasks/src/test/java/fr/altarik/toolbox/task/AsyncTaskTest.java index e6169e1..c73d2a7 100644 --- a/Tasks/src/test/java/fr/altarik/toolbox/AsyncTaskTest.java +++ b/Tasks/src/test/java/fr/altarik/toolbox/task/AsyncTaskTest.java @@ -1,7 +1,6 @@ -package fr.altarik.toolbox; +package fr.altarik.toolbox.task; -import fr.altarik.toolbox.task.AltarikRunnable; -import fr.altarik.toolbox.task.TaskI; +import fr.altarik.toolbox.task.async.AsyncTaskI; import fr.altarik.toolbox.task.async.AsyncTasks; import org.junit.jupiter.api.Test; @@ -21,7 +20,7 @@ class AsyncTaskTest { void testAsyncOp() throws Exception { int numberOfTasks = 10000; System.out.println("Initializing async tasks worker"); - TaskI worker = AsyncTasks.initialize(1); // only testing on a single worker, otherwise result have a high chance to not be in the order we want + AsyncTaskI worker = AsyncTasks.initialize(1); // only testing on a single worker, otherwise result have a high chance to not be in the order we want Stack results = new Stack<>(); for(int i = 0; i < numberOfTasks; i++) { System.out.println(log("sending task " + i)); @@ -40,6 +39,5 @@ class AsyncTaskTest { expected[i] = i; } assertArrayEquals(expected, results.toArray()); - } } diff --git a/Tasks/src/test/java/fr/altarik/toolbox/task/SyncTaskTest.java b/Tasks/src/test/java/fr/altarik/toolbox/task/SyncTaskTest.java new file mode 100644 index 0000000..7095e58 --- /dev/null +++ b/Tasks/src/test/java/fr/altarik/toolbox/task/SyncTaskTest.java @@ -0,0 +1,7 @@ +package fr.altarik.toolbox.task; + +public class SyncTaskTest { + + // TODO: 03/02/2023 Envoyé les tasks au workers grâce à un autre thread. + +}