Package io.debezium.util
Class FunctionalReadWriteLock
java.lang.Object
io.debezium.util.FunctionalReadWriteLock
A form of a read-write lock that has methods that allow lambdas to be performed while the read or write lock is acquired and
held.
- Author:
- Randall Hauch
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic FunctionalReadWriteLock
create
(ReadWriteLock lock) Create a read-write lock around the given standardReadWriteLock
.void
Obtain a read lock, perform the operation, and release the lock.<T> T
Obtain a read lock, perform the operation, and release the read lock.static FunctionalReadWriteLock
Create a read-write lock that supports reentrancy.void
Obtain an exclusive write lock, perform the operation, and release the lock.<T> T
Obtain an exclusive write lock, perform the operation, and release the lock.
-
Field Details
-
lock
-
-
Constructor Details
-
FunctionalReadWriteLock
-
-
Method Details
-
reentrant
Create a read-write lock that supports reentrancy.- Returns:
- the functional read-write lock; never null
-
create
Create a read-write lock around the given standardReadWriteLock
.- Parameters:
lock
- the standard lock; may not be null- Returns:
- the functional read-write lock; never null
-
read
Obtain a read lock, perform the operation, and release the read lock.- Parameters:
operation
- the operation to perform while the read lock is held; may not be null- Returns:
- the result of the operation
-
read
Obtain a read lock, perform the operation, and release the lock.- Parameters:
operation
- the operation to perform while the read lock is held; may not be null
-
write
Obtain an exclusive write lock, perform the operation, and release the lock.- Parameters:
operation
- the operation to perform while the write lock is held; may not be null- Returns:
- the result of the operation
-
write
Obtain an exclusive write lock, perform the operation, and release the lock.- Parameters:
operation
- the operation to perform while the write lock is held; may not be null
-