|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ehcache.concurrent.StripedReadWriteLockSync
public class StripedReadWriteLockSync
Provides a number of Sync which allow fine-grained concurrency. Rather than locking a cache or a store, the individual elements or constituent objects can be locked. This dramatically increases the possible concurrency.
The more stripes, the higher the concurrency. To be threadsafe, the instance of CacheLockProvider needs to be maintained for the entire life of the cache or store, so there is some added memory use. Though a new class, this code has been refactored fromBlockingCache
, where it has been in use
in highly concurrent production environments for years.
Based on the lock striping concept from Brian Goetz. See Java Concurrency in Practice 11.4.3
Field Summary | |
---|---|
static int |
DEFAULT_NUMBER_OF_MUTEXES
The default number of locks to use. |
Constructor Summary | |
---|---|
StripedReadWriteLockSync()
Constructs a striped mutex with the default 2048 stripes. |
|
StripedReadWriteLockSync(int numberOfStripes)
Constructs a striped mutex with the default 2048 stripes. |
Method Summary | |
---|---|
List<ReadWriteLockSync> |
getAllSyncs()
Returns all internal syncs |
ReadWriteLock |
getLockForKey(Object key)
Gets the RWL Stripe to use for a given key. |
ReadWriteLockSync |
getSyncForKey(Object key)
Gets the Sync Stripe to use for a given key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_NUMBER_OF_MUTEXES
Constructor Detail |
---|
public StripedReadWriteLockSync()
public StripedReadWriteLockSync(int numberOfStripes)
numberOfStripes
- - must be a factor of twoMethod Detail |
---|
public ReadWriteLockSync getSyncForKey(Object key)
getSyncForKey
in interface CacheLockProvider
key
- the key
public ReadWriteLock getLockForKey(Object key)
getLockForKey
in interface StripedReadWriteLock
key
- the key
public List<ReadWriteLockSync> getAllSyncs()
getAllSyncs
in interface StripedReadWriteLock
|
ehcache | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |