Skip to content

Commit

Permalink
+ made SequentialExecutor a functional interface by using default method
Browse files Browse the repository at this point in the history
  • Loading branch information
q3769 committed May 15, 2024
1 parent 0892bad commit 77c52b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.q3769</groupId>
<artifactId>conseq4j</artifactId>
<version>20231102.0.20240512</version>
<version>20231102.0.20240515</version>
<packaging>jar</packaging>
<name>conseq4j</name>
<description>A Java concurrent API to sequence related tasks while concurring unrelated ones</description>
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/conseq4j/execute/ConseqExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ private ConseqExecutor(ExecutorService workerExecutorService) {
return new ConseqExecutor(workerExecutorService);
}

/**
* @param command the command to run asynchronously in proper sequence
* @param sequenceKey the key under which this task should be sequenced
* @return future result of the command, not downcast-able from the basic {@link Future} interface.
* @see ConseqExecutor#submit(Callable, Object)
*/
@Override
public @NonNull Future<Void> execute(Runnable command, Object sequenceKey) {
return submit(Executors.callable(command, null), sequenceKey);
}

/**
* Tasks of different sequence keys execute in parallel, pending thread availability from the backing
* {@link #workerExecutorService}.
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/conseq4j/execute/SequentialExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package conseq4j.execute;

import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
Expand All @@ -50,7 +51,9 @@ public interface SequentialExecutor {
* @param sequenceKey the key under which all tasks are executed sequentially
* @return future holding run status of the submitted command
*/
Future<Void> execute(Runnable command, Object sequenceKey);
default Future<Void> execute(Runnable command, Object sequenceKey) {
return submit(Executors.callable(command, null), sequenceKey);
}

/**
* Asynchronously executes specified task in sequence regulated by specified key
Expand Down

0 comments on commit 77c52b9

Please sign in to comment.