Is there a Java library that implements something that behaves like ReadWriteLockbut uses listeners or CompletableFuture / CompletionStage instead of locking?
Ideally, I would like to write:
lock = ...
CompletionStage stage = lock.lockRead();
stage.thenAccept(r -> { doSomething(); r.release(); });
And also important:
CompletionStage stage = lock.tryLockWrite(10, TimeUnit.SECONDS);
stage.handle(callback);
I want to know if something like this exists, and if so, what is it called.
I am not going to implement this myself, but rather use a library to simplify some infrastructure code.
source
share