Class ReadWriteLocked
java.lang.Object
com.helixframework.concurrency.rwlock.ReadWriteLocked
Executes operations with read and write locks.
Non-reentrant read operations are not allowed until all write operations have been finished. Additionally, a write operation can acquire the read lock, but not vice-versa.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()Gets the name of the lock.<T> Tread(ValueOperation<T> op) Executes the read operation with a lock.voidread(VoidOperation op) Executes the read operation with a lock.<T> Twrite(ValueOperation<T> op) Executes the write operation with a lock.voidwrite(VoidOperation op) Executes the write operation with a lock.
-
Constructor Details
-
ReadWriteLocked
public ReadWriteLocked()Creates a lock. -
ReadWriteLocked
Creates a named lock.- Parameters:
name- lock name
-
-
Method Details
-
read
Executes the read operation with a lock.- Type Parameters:
T- operation return type- Parameters:
op- operation- Returns:
- read operation result
-
read
Executes the read operation with a lock.- Parameters:
op- operation
-
write
Executes the write operation with a lock.- Type Parameters:
T- operation return type- Parameters:
op- operation- Returns:
- write operation result
-
write
Executes the write operation with a lock.- Parameters:
op- operation
-
getName
Gets the name of the lock.- Returns:
- name of the lock or
nullif it is not named
-