EDU.oswego.cs.dl.util.concurrent
Class SyncMap
- Map
public class SyncMap
implements Map
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
Writer operations are:
[
Introduction to this package. ]
SyncMap(Map map, ReadWriteLock rwl) - Create a new SyncMap protecting the given map,
and using the given ReadWriteLock to control reader and writer methods.
|
SyncMap(Map map, Sync sync) - Create a new SyncMap protecting the given map,
and using the given sync to control both reader and writer methods.
|
SyncMap(Map map, Sync readLock, Sync writeLock) - Create a new SyncMap protecting the given map,
and using the given pair of locks to control reader and writer methods.
|
rd_
protected final Sync rd_
wr_
protected final Sync wr_
SyncMap
public SyncMap(Map map,
ReadWriteLock rwl)
Create a new SyncMap protecting the given map,
and using the given ReadWriteLock to control reader and writer methods.
SyncMap
public SyncMap(Map map,
Sync sync)
Create a new SyncMap protecting the given map,
and using the given sync to control both reader and writer methods.
Common, reasonable choices for the sync argument include
Mutex, ReentrantLock, and Semaphores initialized to 1.
SyncMap
public SyncMap(Map map,
Sync readLock,
Sync writeLock)
Create a new SyncMap protecting the given map,
and using the given pair of locks to control reader and writer methods.
afterRead
protected void afterRead(boolean wasInterrupted)
Clean up after a reader operation *
beforeRead
protected boolean beforeRead()
Try to acquire sync before a reader operation; record failure *
containsKey
public boolean containsKey(Object o)
containsValue
public boolean containsValue(Object o)
entrySet
public Set entrySet()
equals
public boolean equals(Object o)
get
public Object get(Object key)
hashCode
public int hashCode()
isEmpty
public boolean isEmpty()
keySet
public Set keySet()
put
public Object put(Object key,
Object value)
putAll
public void putAll(Map coll)
readerSync
public Sync readerSync()
Return the Sync object managing read-only operations
remove
public Object remove(Object key)
syncFailures
public long syncFailures()
Return the number of synchronization failures for read-only operations
values
public Collection values()
writerSync
public Sync writerSync()
Return the Sync object managing mutative operations