Fix issue avoiding the mod not to compile, add a test for asyncTasks (still need to be implemented)
Signed-off-by: Quentin Legot <legotquentin@gmail.com>
This commit is contained in:
parent
e7178d44a9
commit
e9c97df089
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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<Integer> 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());
|
||||
|
||||
}
|
||||
}
|
@ -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.
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user