Skip to content
This repository was archived by the owner on May 14, 2018. It is now read-only.

Commit 6c36d1c

Browse files
author
Andrey Kurilov
committed
v2.0.4
1 parent 98fbab4 commit 6c36d1c

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ executed concurrently also.
2525
## Gradle
2626

2727
```groovy
28-
compile group: 'com.github.akurilov', name: 'java-concurrent', version: '2.0.3'
28+
compile group: 'com.github.akurilov', name: 'java-concurrent', version: '2.0.4'
2929
```
3030

3131
## Implementing Basic Coroutine

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ allprojects {
1111
apply plugin: "maven"
1212
apply plugin: "signing"
1313
group = "com.github.akurilov"
14-
version = "2.0.3"
14+
version = "2.0.4"
1515
}
1616

1717
ext.moduleName = "${group}.concurrent"

src/main/java/com/github/akurilov/concurrent/AsyncRunnableBase.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public abstract class AsyncRunnableBase
1616
implements AsyncRunnable {
1717

1818
private volatile State state = State.INITIAL;
19+
1920
private final Lock stateLock = new ReentrantLock();
20-
protected final Condition stateChanged = stateLock.newCondition();
21+
private final Condition stateChanged = stateLock.newCondition();
2122

2223
@Override
2324
public final State state() {
@@ -176,18 +177,15 @@ public void close()
176177
} catch(final IllegalStateException ignored) {
177178
}
178179
// then close actually
179-
if(stateLock.tryLock()) {
180-
try {
181-
if(null != state) {
182-
doClose();
183-
state = null;
184-
stateChanged.signalAll();
185-
}
186-
} finally {
187-
stateLock.unlock();
180+
stateLock.lock();
181+
try {
182+
if(null != state) {
183+
doClose();
184+
state = null;
185+
stateChanged.signalAll();
188186
}
189-
} else {
190-
throw new IllegalStateException("Close: failed to acquire the state lock");
187+
} finally {
188+
stateLock.unlock();
191189
}
192190
}
193191

0 commit comments

Comments
 (0)