Skip to content

Commit e4ba7ae

Browse files
committed
fix LockPoint
1 parent fa73a7f commit e4ba7ae

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

net.lecousin.core/src/main/java/net/lecousin/framework/concurrent/async/LockPoint.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,21 @@ public void lock() {
3030
return;
3131
if (error != null)
3232
return;
33-
Blockable blockable;
3433
do {
34+
Blockable blockable;
3535
synchronized (this) {
3636
if (!locked) {
3737
locked = true;
3838
return;
3939
}
4040
blockable = Threading.getBlockable();
41-
if (blockable != null) break;
42-
try { this.wait(0); }
43-
catch (InterruptedException e) { /* continue anyway */ }
41+
if (blockable == null)
42+
try { this.wait(0); }
43+
catch (InterruptedException e) { /* continue anyway */ }
4444
}
45+
if (blockable != null)
46+
blockable.blocked(this, 0);
4547
} while (true);
46-
blockable.blocked(this, 0);
4748
}
4849

4950
/** Release the lock. */

net.lecousin.core/src/main/java/net/lecousin/framework/io/out2in/OutputToInput.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,11 @@ public AsyncSupplier<Integer, IOException> readAsync(long pos, ByteBuffer buffer
215215
int lim = buffer.limit();
216216
if (writePos - pos < buffer.remaining())
217217
buffer.limit(buffer.position() + (int)(writePos - pos));
218-
AsyncSupplier<Integer, IOException> read = ((IO.Readable.Seekable)io).readAsync(pos, buffer, ondone);
219-
read.onDone(() -> {
218+
((IO.Readable.Seekable)io).readAsync(pos, buffer, res -> {
220219
buffer.limit(lim);
221220
lockIO.unlock();
222-
read.forward(result);
223-
});
221+
if (ondone != null) ondone.accept(res);
222+
}).forward(result);
224223
return null;
225224
}).start();
226225
return operation(result);

0 commit comments

Comments
 (0)