Package com.globalmentor.collections
Class DecoratorReadWriteLockSet<E>
- java.lang.Object
-
- com.globalmentor.collections.ReadWriteLockDecorator
-
- com.globalmentor.collections.DecoratorReadWriteLockCollection<E>
-
- com.globalmentor.collections.DecoratorReadWriteLockSet<E>
-
- Type Parameters:
E
- The type of elements in the set.
- All Implemented Interfaces:
ReadWriteLockCollection<E>
,ReadWriteLockSet<E>
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.concurrent.locks.ReadWriteLock
,java.util.Set<E>
public class DecoratorReadWriteLockSet<E> extends DecoratorReadWriteLockCollection<E> implements ReadWriteLockSet<E>
A thread-safe collection decorator that allows many readers but only one writer to access a set at a time. For operations that iterate over live collection data, a read or write lock should be acquired before the call to acquire the data and held until the data is consumed.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description DecoratorReadWriteLockSet(java.util.Set<E> set)
Set constructor with a default reentrant read/write lock.DecoratorReadWriteLockSet(java.util.Set<E> set, java.util.concurrent.locks.ReadWriteLock lock)
Set and read/write lock constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Set<E>
getCollection()
-
Methods inherited from class com.globalmentor.collections.DecoratorReadWriteLockCollection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
-
Methods inherited from class com.globalmentor.collections.ReadWriteLockDecorator
readLock, writeLock
-
-
-
-
Constructor Detail
-
DecoratorReadWriteLockSet
public DecoratorReadWriteLockSet(java.util.Set<E> set)
Set constructor with a default reentrant read/write lock.- Parameters:
set
- The set this set should decorate.- Throws:
java.lang.NullPointerException
- if the provided set isnull
.
-
DecoratorReadWriteLockSet
public DecoratorReadWriteLockSet(java.util.Set<E> set, java.util.concurrent.locks.ReadWriteLock lock)
Set and read/write lock constructor.- Parameters:
set
- The set this set should decorate.lock
- The lock for controlling access to the set.- Throws:
java.lang.NullPointerException
- if the provided set and/or lock isnull
.
-
-
Method Detail
-
getCollection
protected java.util.Set<E> getCollection()
- Overrides:
getCollection
in classDecoratorReadWriteLockCollection<E>
- Returns:
- The collection this class decorates.
-
-