Skip to content

Commit 8126a44

Browse files
committed
Preparing release
1 parent 13d043c commit 8126a44

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate.concurrent/net.tascalate.concurrent.lib.svg)](https://search.maven.org/artifact/net.tascalate.concurrent/net.tascalate.concurrent.lib/0.6.6/jar) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-concurrent.svg)](https://github.com/vsilaev/tascalate-concurrent/releases/tag/0.6.6) [![license](https://img.shields.io/github/license/vsilaev/tascalate-concurrent.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
1+
[![Maven Central](https://img.shields.io/maven-central/v/net.tascalate.concurrent/net.tascalate.concurrent.lib.svg)](https://search.maven.org/artifact/net.tascalate.concurrent/net.tascalate.concurrent.lib/0.6.7/jar) [![GitHub release](https://img.shields.io/github/release/vsilaev/tascalate-concurrent.svg)](https://github.com/vsilaev/tascalate-concurrent/releases/tag/0.6.7) [![license](https://img.shields.io/github/license/vsilaev/tascalate-concurrent.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
22
# tascalate-concurrent
33
The library provides an implementation of the CompletionStage interface and related classes these are designed to support long-running blocking tasks (typically, I/O bound) - unlike Java 8 built-in implementation, [CompletableFuture](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html), that is primarily supports computational tasks.
44
# Why a CompletableFuture is not enough?
@@ -13,7 +13,7 @@ Add Maven dependency
1313
<dependency>
1414
<groupId>net.tascalate.concurrent</groupId>
1515
<artifactId>net.tascalate.concurrent.lib</artifactId>
16-
<version>0.6.6</version>
16+
<version>0.6.7</version>
1717
</dependency>
1818
```
1919

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>net.tascalate.concurrent</groupId>
66
<artifactId>net.tascalate.concurrent.lib</artifactId>
7-
<version>0.6.7-SNAPSHOT</version>
7+
<version>0.6.7</version>
88
<packaging>jar</packaging>
99

1010
<name>Tascalate Concurrenct</name>

src/main/java/net/tascalate/concurrent/CompletableSubTask.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import java.util.concurrent.Callable;
1919
import java.util.concurrent.Executor;
20-
import java.util.concurrent.atomic.AtomicBoolean;
20+
import java.util.concurrent.atomic.AtomicReference;
2121

2222
/**
2323
* The {@link Promise} implementation for intermediate long-running blocking task
@@ -29,20 +29,19 @@ class CompletableSubTask<T> extends AbstractCompletableTask<T> {
2929

3030
static class DelegatingCallable<T> implements Callable<T> {
3131

32-
final private AtomicBoolean setupGuard = new AtomicBoolean(false);
33-
private Callable<T> delegate;
32+
final private AtomicReference<Callable<T>> delegateRef = new AtomicReference<>(null);
3433

3534
void setup(Callable<T> delegate) {
36-
if (setupGuard.compareAndSet(false, true)) {
37-
this.delegate = delegate;
38-
} else {
35+
boolean updated = delegateRef.compareAndSet(null, delegate);
36+
if (!updated) {
3937
throw new IllegalStateException("Delegate may be set only once");
4038
}
4139
}
4240

4341
@Override
4442
public T call() throws Exception {
45-
if (!setupGuard.get()) {
43+
Callable<T> delegate = delegateRef.get();
44+
if (null == delegate) {
4645
throw new IllegalStateException("Call is not configured");
4746
} else {
4847
return delegate.call();

0 commit comments

Comments
 (0)