Class SyncMap
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SyncMap
- All Implemented Interfaces:
Map
- Direct Known Subclasses:
SyncSortedMap
SyncMaps wrap Sync-based control around java.util.Maps.
They operate in the same way as SyncCollection.
Reader operations are
- size
- isEmpty
- get
- containsKey
- containsValue
- keySet
- entrySet
- values
- put
- putAll
- remove
- clear
- See Also:
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Mapprotected final Syncprotected final SynchronizedLongprotected final Sync -
Constructor Summary
ConstructorsConstructorDescriptionSyncMap(Map map, ReadWriteLock rwl) Create a new SyncMap protecting the given map, and using the given ReadWriteLock to control reader and writer methods.Create a new SyncMap protecting the given map, and using the given sync to control both reader and writer methods.Create a new SyncMap protecting the given map, and using the given pair of locks to control reader and writer methods. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterRead(boolean wasInterrupted) Clean up after a reader operationprotected booleanTry to acquire sync before a reader operation; record failurevoidclear()booleanbooleanentrySet()booleaninthashCode()booleanisEmpty()keySet()voidReturn the Sync object managing read-only operationsintsize()longReturn the number of synchronization failures for read-only operationsvalues()Return the Sync object managing mutative operationsMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
c_
-
rd_
-
wr_
-
syncFailures_
-
-
Constructor Details
-
SyncMap
-
SyncMap
Create a new SyncMap protecting the given map, and using the given ReadWriteLock to control reader and writer methods. -
SyncMap
-
-
Method Details
-
readerSync
Return the Sync object managing read-only operations -
writerSync
Return the Sync object managing mutative operations -
syncFailures
public long syncFailures()Return the number of synchronization failures for read-only operations -
beforeRead
protected boolean beforeRead()Try to acquire sync before a reader operation; record failure -
afterRead
protected void afterRead(boolean wasInterrupted) Clean up after a reader operation -
hashCode
-
equals
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap
-
containsValue
- Specified by:
containsValuein interfaceMap
-
get
-
put
-
remove
-
putAll
-
clear
-
keySet
-
entrySet
-
values
-