public interface LockedResource<T> extends Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
ensureAcquiredOrThrow(String lostLockMessage)
Checks if the lock is still acquired or throws a
LostLockException. |
T |
getResource() |
void ensureAcquiredOrThrow(String lostLockMessage) throws LostLockException
LostLockException.
Code that relies on a lock should perform this check at critical points.
You should catch the LostLockException if you need to perform any clean up around
losing the lock. The thrown exception will include the provided lostLockMessage which
should explain what will happen as a result of the lock being lost.
If the check fails for another reason, we pessimistically assume the lock was lost, so
a LostLockException is also thrown, with the underlying failure as its cause.
In any case that this method throws LostLockException, no further resource clean
up is necessary. The implementation should take care of any necessary cleanup on behalf of the
client since we are giving up on the lock... it is lost, after all.
LostLockExceptionT getResource()
Copyright © 2017. All rights reserved.