This repository was archived by the owner on May 14, 2018. It is now read-only.
File tree 3 files changed +12
-14
lines changed
src/main/java/com/github/akurilov/concurrent 3 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ executed concurrently also.
25
25
## Gradle
26
26
27
27
``` 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 '
29
29
```
30
30
31
31
## Implementing Basic Coroutine
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ allprojects {
11
11
apply plugin : " maven"
12
12
apply plugin : " signing"
13
13
group = " com.github.akurilov"
14
- version = " 2.0.3 "
14
+ version = " 2.0.4 "
15
15
}
16
16
17
17
ext. moduleName = " ${ group} .concurrent"
Original file line number Diff line number Diff line change @@ -16,8 +16,9 @@ public abstract class AsyncRunnableBase
16
16
implements AsyncRunnable {
17
17
18
18
private volatile State state = State .INITIAL ;
19
+
19
20
private final Lock stateLock = new ReentrantLock ();
20
- protected final Condition stateChanged = stateLock .newCondition ();
21
+ private final Condition stateChanged = stateLock .newCondition ();
21
22
22
23
@ Override
23
24
public final State state () {
@@ -176,18 +177,15 @@ public void close()
176
177
} catch (final IllegalStateException ignored ) {
177
178
}
178
179
// 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 ();
188
186
}
189
- } else {
190
- throw new IllegalStateException ( "Close: failed to acquire the state lock" );
187
+ } finally {
188
+ stateLock . unlock ( );
191
189
}
192
190
}
193
191
You can’t perform that action at this time.
0 commit comments