Skip to content

Commit 28db313

Browse files
committed
+ made SequentialExecutor a functional interface using default method
1 parent 8016870 commit 28db313

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<modelVersion>4.0.0</modelVersion>
2828
<groupId>io.github.q3769</groupId>
2929
<artifactId>conseq4j</artifactId>
30-
<version>20230922.20230924.20240515</version>
30+
<version>20230922.20230924.20240516</version>
3131
<packaging>jar</packaging>
3232
<name>conseq4j</name>
3333
<description>A Java concurrent API to sequence related tasks while concurring unrelated ones</description>

src/main/java/conseq4j/execute/ConseqExecutor.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@
3030
import conseq4j.Terminable;
3131
import java.util.List;
3232
import java.util.Map;
33-
import java.util.concurrent.Callable;
34-
import java.util.concurrent.CompletableFuture;
35-
import java.util.concurrent.ConcurrentHashMap;
36-
import java.util.concurrent.ConcurrentMap;
37-
import java.util.concurrent.ExecutorService;
38-
import java.util.concurrent.Executors;
39-
import java.util.concurrent.Future;
33+
import java.util.concurrent.*;
4034
import javax.annotation.Nonnull;
4135
import javax.annotation.concurrent.ThreadSafe;
4236
import lombok.NonNull;
@@ -93,17 +87,6 @@ private static ConditionFactory await() {
9387
return Awaitility.await().forever();
9488
}
9589

96-
/**
97-
* @param command the command to run asynchronously in proper sequence
98-
* @param sequenceKey the key under which this task should be sequenced
99-
* @return future result of the command, not downcast-able from the basic {@link Future} interface.
100-
* @see ConseqExecutor#submit(Callable, Object)
101-
*/
102-
@Override
103-
public @NonNull Future<Void> execute(@NonNull Runnable command, @NonNull Object sequenceKey) {
104-
return submit(Executors.callable(command, null), sequenceKey);
105-
}
106-
10790
/**
10891
* Tasks of different sequence keys execute in parallel, pending thread availability from the backing
10992
* {@link #workerExecutorService}.

src/main/java/conseq4j/execute/SequentialExecutor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package conseq4j.execute;
2626

2727
import java.util.concurrent.Callable;
28+
import java.util.concurrent.Executors;
2829
import java.util.concurrent.Future;
2930

3031
/**
@@ -48,8 +49,9 @@ public interface SequentialExecutor {
4849
* @param sequenceKey the key under which all tasks are executed sequentially
4950
* @return future holding run status of the submitted command
5051
*/
51-
Future<Void> execute(Runnable command, Object sequenceKey);
52-
52+
default Future<Void> execute(Runnable command, Object sequenceKey) {
53+
return submit(Executors.callable(command, null), sequenceKey);
54+
}
5355
/**
5456
* @param task the Callable task to run sequentially with others under the same sequence key
5557
* @param sequenceKey the key under which all tasks are executed sequentially

0 commit comments

Comments
 (0)