Top Description Inners Fields Constructors Methods
com.google.common.util.concurrent

public abstract Class Striped<L>

extends Object
Class Inheritance
Known Direct Subclasses
com.google.common.util.concurrent.Striped.PowerOfTwoStriped
Annotations
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.collect.Lists.newArrayList

A striped Lock/Semaphore/ReadWriteLock. This offers the underlying lock striping similar to that of ConcurrentHashMap in a reusable form, and extends it for semaphores and read-write locks. Conceptually, lock striping is the technique of dividing a lock into many stripes, increasing the granularity of a single lock and allowing independent operations to lock different stripes and proceed concurrently, instead of creating contention for a single lock.

The guarantee provided by this class is that equal keys lead to the same lock (or semaphore), i.e. if (key1.equals(key2)) then striped.get(key1) == striped.get(key2) (assuming Object#hashCode() is correctly implemented for the keys). Note that if key1 is not equal to key2, it is not guaranteed that striped.get(key1) != striped.get(key2); the elements might nevertheless be mapped to the same lock. The lower the number of stripes, the higher the probability of this happening.

There are three flavors of this class: Striped<Lock>, Striped<Semaphore>, and Striped<ReadWriteLock>. For each type, two implementations are offered: strong and weak Striped<Lock>, strong and weak Striped<Semaphore>, and strong and weak Striped<ReadWriteLock>. Strong means that all stripes (locks/semaphores) are initialized eagerly, and are not reclaimed unless Striped itself is reclaimable. Weak means that locks/semaphores are created lazily, and they are allowed to be reclaimed if nobody is holding on to them. This is useful, for example, if one wants to create a Striped<Lock> of many locks, but worries that in most cases only a small portion of these would be in use.

Prior to this class, one might be tempted to use Map<K, Lock>, where K represents the task. This maximizes concurrency by having each unique key mapped to a unique lock, but also maximizes memory footprint. On the other extreme, one could use a single lock for all tasks, which minimizes memory footprint but also minimizes concurrency. Instead of choosing either of these extremes, Striped allows the user to trade between required concurrency and memory footprint. For example, if a set of tasks are CPU-bound, one could easily create a very compact Striped<Lock> of availableProcessors() * 4 stripes, instead of possibly thousands of locks which could be created in a Map<K, Lock> structure.

Author
Dimitris Andreou
Since
13.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Striped.CompactStriped<L>

Implementation of Striped where 2^k stripes are represented as an array of the same length, eagerly initialized.

pack-priv static class
Striped.LargeLazyStriped<L>

Implementation of Striped where up to 2^k stripes can be represented, using a ConcurrentMap where the key domain is [0..2^k).

private static class
private static class
private abstract static class
pack-priv static class
Striped.SmallLazyStriped<L>

Implementation of Striped where up to 2^k stripes can be represented, using an AtomicReferenceArray of size 2^k.

private static class
Striped.WeakSafeCondition

Condition object that ensures a strong reference is retained to a specified object.

private static class
Striped.WeakSafeLock

Lock object that ensures a strong reference is retained to a specified object.

private static class
Striped.WeakSafeReadWriteLock

ReadWriteLock implementation whose read and write locks retain a reference back to this lock.

Field Summary

Modifier and TypeField and Description
private static final int
ALL_SET

A bit mask were all bits are set.

private static final int
LARGE_LAZY_CUTOFF

If there are at least this many stripes, we assume the memory usage of a ConcurrentMap will be smaller than a large array.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Iterable<L>

Returns:

the stripes corresponding to the objects (one per each object, derived by delegating to get(Object); may contain duplicates), in an increasing index order.
bulkGet
(Iterable<? extends Object>
arbitrary non-null keys
keys
)

Returns the stripes that correspond to the passed objects, in ascending (as per getAt(int)) order.

private static int
pack-priv static <L> Striped<L>

Returns:

a new Striped<L>
custom
(int
the minimum number of stripes (locks) required
stripes
,
Supplier<L>
a Supplier<L> object to obtain locks from
supplier
)

Creates a Striped<L> with eagerly initialized, strongly referenced locks.

public abstract L

Returns:

the stripe that the passed key corresponds to
get
(Object
an arbitrary, non-null key
key
)

Returns the stripe that corresponds to the passed key.

public abstract L

Returns:

the stripe at the specified index
getAt
(int
the index of the stripe to return; must be in [0...size())
index
)

Returns the stripe at the specified index.

pack-priv abstract int
indexFor(Object key)

Returns the index to which the given key is mapped, so that getAt(indexFor(key)) == get(key).

private static <L> Striped<L>
lazy(int stripes, Supplier<L> supplier)

public static Striped<Lock>

Returns:

a new Striped<Lock>
lazyWeakLock
(int
the minimum number of stripes (locks) required
stripes
)

Creates a Striped<Lock> with lazily initialized, weakly referenced locks.

public static Striped<ReadWriteLock>

Returns:

a new Striped<ReadWriteLock>
lazyWeakReadWriteLock
(int
the minimum number of stripes (locks) required
stripes
)

Creates a Striped<ReadWriteLock> with lazily initialized, weakly referenced read-write locks.

public static Striped<Semaphore>

Returns:

a new Striped<Semaphore>
lazyWeakSemaphore
(int
the minimum number of stripes (semaphores) required
stripes
,
int
the number of permits in each semaphore
permits
)

Creates a Striped<Semaphore> with lazily initialized, weakly referenced semaphores, with the specified number of permits.

public static Striped<Lock>

Returns:

a new Striped<Lock>
lock
(int
the minimum number of stripes (locks) required
stripes
)

Creates a Striped<Lock> with eagerly initialized, strongly referenced locks.

public static Striped<ReadWriteLock>

Returns:

a new Striped<ReadWriteLock>
readWriteLock
(int
the minimum number of stripes (locks) required
stripes
)

Creates a Striped<ReadWriteLock> with eagerly initialized, strongly referenced read-write locks.

public static Striped<Semaphore>

Returns:

a new Striped<Semaphore>
semaphore
(int
the minimum number of stripes (semaphores) required
stripes
,
int
the number of permits in each semaphore
permits
)

Creates a Striped<Semaphore> with eagerly initialized, strongly referenced semaphores, with the specified number of permits.

public abstract int
size()

Returns the total number of stripes in this instance.

private static int
smear(int hashCode)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALL_SETback to summary
private static final int ALL_SET

A bit mask were all bits are set.

LARGE_LAZY_CUTOFFback to summary
private static final int LARGE_LAZY_CUTOFF

If there are at least this many stripes, we assume the memory usage of a ConcurrentMap will be smaller than a large array. (This assumes that in the lazy case, most stripes are unused. As always, if many stripes are in use, a non-lazy striped makes more sense.)

Constructor Detail

Stripedback to summary
private Striped()

Method Detail

bulkGetback to summary
public Iterable<L> bulkGet(Iterable<? extends Object> keys)

Returns the stripes that correspond to the passed objects, in ascending (as per getAt(int)) order. Thus, threads that use the stripes in the order returned by this method are guaranteed to not deadlock each other.

It should be noted that using a Striped<L> with relatively few stripes, and bulkGet(keys) with a relative large number of keys can cause an excessive number of shared stripes (much like the birthday paradox, where much fewer than anticipated birthdays are needed for a pair of them to match). Please consider carefully the implications of the number of stripes, the intended concurrency level, and the typical number of keys used in a bulkGet(keys) operation. See Balls in Bins model for mathematical formulas that can be used to estimate the probability of collisions.

Parameters
keys:Iterable<? extends Object>

arbitrary non-null keys

Returns:Iterable<L>

the stripes corresponding to the objects (one per each object, derived by delegating to get(Object); may contain duplicates), in an increasing index order.

ceilToPowerOfTwoback to summary
private static int ceilToPowerOfTwo(int x)
customback to summary
pack-priv static <L> Striped<L> custom(int stripes, Supplier<L> supplier)

Creates a Striped<L> with eagerly initialized, strongly referenced locks. Every lock is obtained from the passed supplier.

Parameters
stripes:int

the minimum number of stripes (locks) required

supplier:Supplier<L>

a Supplier<L> object to obtain locks from

Returns:Striped<L>

a new Striped<L>

getback to summary
public abstract L get(Object key)

Returns the stripe that corresponds to the passed key. It is always guaranteed that if key1.equals(key2), then get(key1) == get(key2).

Parameters
key:Object

an arbitrary, non-null key

Returns:L

the stripe that the passed key corresponds to

getAtback to summary
public abstract L getAt(int index)

Returns the stripe at the specified index. Valid indexes are 0, inclusively, to size(), exclusively.

Parameters
index:int

the index of the stripe to return; must be in [0...size())

Returns:L

the stripe at the specified index

indexForback to summary
pack-priv abstract int indexFor(Object key)

Returns the index to which the given key is mapped, so that getAt(indexFor(key)) == get(key).

lazyback to summary
private static <L> Striped<L> lazy(int stripes, Supplier<L> supplier)
lazyWeakLockback to summary
public static Striped<Lock> lazyWeakLock(int stripes)

Creates a Striped<Lock> with lazily initialized, weakly referenced locks. Every lock is reentrant.

Parameters
stripes:int

the minimum number of stripes (locks) required

Returns:Striped<Lock>

a new Striped<Lock>

lazyWeakReadWriteLockback to summary
public static Striped<ReadWriteLock> lazyWeakReadWriteLock(int stripes)

Creates a Striped<ReadWriteLock> with lazily initialized, weakly referenced read-write locks. Every lock is reentrant.

Parameters
stripes:int

the minimum number of stripes (locks) required

Returns:Striped<ReadWriteLock>

a new Striped<ReadWriteLock>

lazyWeakSemaphoreback to summary
public static Striped<Semaphore> lazyWeakSemaphore(int stripes, int permits)

Creates a Striped<Semaphore> with lazily initialized, weakly referenced semaphores, with the specified number of permits.

Parameters
stripes:int

the minimum number of stripes (semaphores) required

permits:int

the number of permits in each semaphore

Returns:Striped<Semaphore>

a new Striped<Semaphore>

lockback to summary
public static Striped<Lock> lock(int stripes)

Creates a Striped<Lock> with eagerly initialized, strongly referenced locks. Every lock is reentrant.

Parameters
stripes:int

the minimum number of stripes (locks) required

Returns:Striped<Lock>

a new Striped<Lock>

readWriteLockback to summary
public static Striped<ReadWriteLock> readWriteLock(int stripes)

Creates a Striped<ReadWriteLock> with eagerly initialized, strongly referenced read-write locks. Every lock is reentrant.

Parameters
stripes:int

the minimum number of stripes (locks) required

Returns:Striped<ReadWriteLock>

a new Striped<ReadWriteLock>

semaphoreback to summary
public static Striped<Semaphore> semaphore(int stripes, int permits)

Creates a Striped<Semaphore> with eagerly initialized, strongly referenced semaphores, with the specified number of permits.

Parameters
stripes:int

the minimum number of stripes (semaphores) required

permits:int

the number of permits in each semaphore

Returns:Striped<Semaphore>

a new Striped<Semaphore>

sizeback to summary
public abstract int size()

Returns the total number of stripes in this instance.

smearback to summary
private static int smear(int hashCode)
com.google.common.util.concurrent back to summary

private Class Striped.CompactStriped<L>

extends Striped.PowerOfTwoStriped<L>
Class Inheritance

Implementation of Striped where 2^k stripes are represented as an array of the same length, eagerly initialized.

Field Summary

Modifier and TypeField and Description
private final Object[]
array

Size is a power of two.

Inherited from com.google.common.util.concurrent.Striped.PowerOfTwoStriped:
mask

Constructor Summary

AccessConstructor and Description
private
CompactStriped(int stripes, Supplier<L> supplier)

Method Summary

Modifier and TypeMethod and Description
public L
getAt(int
the index of the stripe to return; must be in [0...size())
index
)

Implements abstract com.google.common.util.concurrent.Striped.getAt.

Returns the stripe at the specified index.
public int
size()

Implements abstract com.google.common.util.concurrent.Striped.size.

Returns the total number of stripes in this instance.
Inherited from com.google.common.util.concurrent.Striped.PowerOfTwoStriped:
getindexFor

Field Detail

arrayback to summary
private final Object[] array

Size is a power of two.

Constructor Detail

CompactStripedback to summary
private CompactStriped(int stripes, Supplier<L> supplier)

Method Detail

getAtback to summary
public L getAt(int index)

Implements abstract com.google.common.util.concurrent.Striped.getAt.

Doc from com.google.common.util.concurrent.Striped.getAt.

Returns the stripe at the specified index. Valid indexes are 0, inclusively, to size(), exclusively.

Parameters
index:int

the index of the stripe to return; must be in [0...size())

Returns:L

the stripe at the specified index

Annotations
@SuppressWarnings:unchecked
@Override
sizeback to summary
public int size()

Implements abstract com.google.common.util.concurrent.Striped.size.

Doc from com.google.common.util.concurrent.Striped.size.

Returns the total number of stripes in this instance.

Annotations
@Override
com.google.common.util.concurrent back to summary

pack-priv Class Striped.LargeLazyStriped<L>

extends Striped.PowerOfTwoStriped<L>
Class Inheritance
Annotations
@VisibleForTesting

Implementation of Striped where up to 2^k stripes can be represented, using a ConcurrentMap where the key domain is [0..2^k). To map a user key into a stripe, we take a k-bit slice of the user key's (smeared) hashCode(). The stripes are lazily initialized and are weakly referenced.

Field Summary

Modifier and TypeField and Description
pack-priv final ConcurrentMap<Integer, L>
pack-priv final int
pack-priv final Supplier<L>
Inherited from com.google.common.util.concurrent.Striped.PowerOfTwoStriped:
mask

Constructor Summary

AccessConstructor and Description
pack-priv
LargeLazyStriped(int stripes, Supplier<L> supplier)

Method Summary

Modifier and TypeMethod and Description
public L
getAt(int
the index of the stripe to return; must be in [0...size())
index
)

Implements abstract com.google.common.util.concurrent.Striped.getAt.

Returns the stripe at the specified index.
public int
size()

Implements abstract com.google.common.util.concurrent.Striped.size.

Returns the total number of stripes in this instance.
Inherited from com.google.common.util.concurrent.Striped.PowerOfTwoStriped:
getindexFor

Field Detail

locksback to summary
pack-priv final ConcurrentMap<Integer, L> locks
sizeback to summary
pack-priv final int size
supplierback to summary
pack-priv final Supplier<L> supplier

Constructor Detail

LargeLazyStripedback to summary
pack-priv LargeLazyStriped(int stripes, Supplier<L> supplier)

Method Detail

getAtback to summary
public L getAt(int index)

Implements abstract com.google.common.util.concurrent.Striped.getAt.

Doc from com.google.common.util.concurrent.Striped.getAt.

Returns the stripe at the specified index. Valid indexes are 0, inclusively, to size(), exclusively.

Parameters
index:int

the index of the stripe to return; must be in [0...size())

Returns:L

the stripe at the specified index

Annotations
@Override
sizeback to summary
public int size()

Implements abstract com.google.common.util.concurrent.Striped.size.

Doc from com.google.common.util.concurrent.Striped.size.

Returns the total number of stripes in this instance.

Annotations
@Override
com.google.common.util.concurrent back to summary

private Class Striped.PaddedLock

extends ReentrantLock
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv long
pack-priv long
pack-priv long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.util.concurrent.locks.ReentrantLock:
getHoldCountgetOwnergetQueuedThreadsgetQueueLengthgetWaitingThreadsgetWaitQueueLengthhasQueuedThreadhasQueuedThreadshasWaitersisFairisHeldByCurrentThreadisLockedlocklockInterruptiblynewConditiontoStringtryLocktryLockunlock

Field Detail

unused1back to summary
pack-priv long unused1
unused2back to summary
pack-priv long unused2
unused3back to summary
pack-priv long unused3

Constructor Detail

PaddedLockback to summary
pack-priv PaddedLock()
com.google.common.util.concurrent back to summary

private Class Striped.PaddedSemaphore

extends Semaphore
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv long
pack-priv long
pack-priv long

Constructor Summary

AccessConstructor and Description
pack-priv
PaddedSemaphore(int permits)

Method Summary

Inherited from java.util.concurrent.Semaphore:
acquireacquireacquireUninterruptiblyacquireUninterruptiblyavailablePermitsdrainPermitsgetQueuedThreadsgetQueueLengthhasQueuedThreadsisFairreducePermitsreleasereleasetoStringtryAcquiretryAcquiretryAcquiretryAcquire

Field Detail

unused1back to summary
pack-priv long unused1
unused2back to summary
pack-priv long unused2
unused3back to summary
pack-priv long unused3

Constructor Detail

PaddedSemaphoreback to summary
pack-priv PaddedSemaphore(int permits)
com.google.common.util.concurrent back to summary

private abstract Class Striped.PowerOfTwoStriped<L>

extends Striped<L>
Class Inheritance
Known Direct Subclasses
com.google.common.util.concurrent.Striped.CompactStriped, com.google.common.util.concurrent.Striped.SmallLazyStriped, com.google.common.util.concurrent.Striped.LargeLazyStriped

Field Summary

Modifier and TypeField and Description
pack-priv final int
mask

Capacity (power of two) minus one, for fast mod evaluation

Constructor Summary

AccessConstructor and Description
pack-priv
PowerOfTwoStriped(int stripes)

Method Summary

Modifier and TypeMethod and Description
public final L
get(Object
an arbitrary, non-null key
key
)

Implements abstract com.google.common.util.concurrent.Striped.get.

Returns the stripe that corresponds to the passed key.
pack-priv final int
indexFor(Object key)

Implements abstract com.google.common.util.concurrent.Striped.indexFor.

Returns the index to which the given key is mapped, so that getAt(indexFor(key)) == get(key).
Inherited from com.google.common.util.concurrent.Striped:
bulkGetcustomgetAtlazyWeakLocklazyWeakReadWriteLocklazyWeakSemaphorelockreadWriteLocksemaphoresize

Field Detail

maskback to summary
pack-priv final int mask

Capacity (power of two) minus one, for fast mod evaluation

Constructor Detail

PowerOfTwoStripedback to summary
pack-priv PowerOfTwoStriped(int stripes)

Method Detail

getback to summary
public final L get(Object key)

Implements abstract com.google.common.util.concurrent.Striped.get.

Doc from com.google.common.util.concurrent.Striped.get.

Returns the stripe that corresponds to the passed key. It is always guaranteed that if key1.equals(key2), then get(key1) == get(key2).

Parameters
key:Object

an arbitrary, non-null key

Returns:L

the stripe that the passed key corresponds to

Annotations
@Override
indexForback to summary
pack-priv final int indexFor(Object key)

Implements abstract com.google.common.util.concurrent.Striped.indexFor.

Doc from com.google.common.util.concurrent.Striped.indexFor.

Returns the index to which the given key is mapped, so that getAt(indexFor(key)) == get(key).

Annotations
@Override
com.google.common.util.concurrent back to summary

pack-priv Class Striped.SmallLazyStriped<L>

extends Striped.PowerOfTwoStriped<L>
Class Inheritance
Annotations
@VisibleForTesting

Implementation of Striped where up to 2^k stripes can be represented, using an AtomicReferenceArray of size 2^k. To map a user key into a stripe, we take a k-bit slice of the user key's (smeared) hashCode(). The stripes are lazily initialized and are weakly referenced.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicReferenceArray<@Nullable Striped.SmallLazyStriped.ArrayReference<? extends L>>
pack-priv final ReferenceQueue<L>
pack-priv final int
pack-priv final Supplier<L>
Inherited from com.google.common.util.concurrent.Striped.PowerOfTwoStriped:
mask

Constructor Summary

AccessConstructor and Description
pack-priv
SmallLazyStriped(int stripes, Supplier<L> supplier)

Method Summary

Modifier and TypeMethod and Description
private void
public L
getAt(int
the index of the stripe to return; must be in [0...size())
index
)

Implements abstract com.google.common.util.concurrent.Striped.getAt.

Returns the stripe at the specified index.
public int
size()

Implements abstract com.google.common.util.concurrent.Striped.size.

Returns the total number of stripes in this instance.
Inherited from com.google.common.util.concurrent.Striped.PowerOfTwoStriped:
getindexFor

Field Detail

locksback to summary
pack-priv final AtomicReferenceArray<@Nullable Striped.SmallLazyStriped.ArrayReference<? extends L>> locks
queueback to summary
pack-priv final ReferenceQueue<L> queue
sizeback to summary
pack-priv final int size
supplierback to summary
pack-priv final Supplier<L> supplier

Constructor Detail

SmallLazyStripedback to summary
pack-priv SmallLazyStriped(int stripes, Supplier<L> supplier)

Method Detail

drainQueueback to summary
private void drainQueue()
getAtback to summary
public L getAt(int index)

Implements abstract com.google.common.util.concurrent.Striped.getAt.

Doc from com.google.common.util.concurrent.Striped.getAt.

Returns the stripe at the specified index. Valid indexes are 0, inclusively, to size(), exclusively.

Parameters
index:int

the index of the stripe to return; must be in [0...size())

Returns:L

the stripe at the specified index

Annotations
@Override
sizeback to summary
public int size()

Implements abstract com.google.common.util.concurrent.Striped.size.

Doc from com.google.common.util.concurrent.Striped.size.

Returns the total number of stripes in this instance.

Annotations
@Override
com.google.common.util.concurrent back to summary

private final Class Striped.SmallLazyStriped.ArrayReference<L>

extends WeakReference<L>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int

Constructor Summary

AccessConstructor and Description
pack-priv
ArrayReference(L referent, int index, ReferenceQueue<L> queue)

Field Detail

indexback to summary
pack-priv final int index

Constructor Detail

ArrayReferenceback to summary
pack-priv ArrayReference(L referent, int index, ReferenceQueue<L> queue)
com.google.common.util.concurrent back to summary

private final Class Striped.WeakSafeCondition

extends ForwardingCondition
Class Inheritance

Condition object that ensures a strong reference is retained to a specified object.

Field Summary

Modifier and TypeField and Description
private final Condition
private final Striped.WeakSafeReadWriteLock

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv Condition
Inherited from com.google.common.util.concurrent.ForwardingCondition:
awaitawaitawaitNanosawaitUninterruptiblyawaitUntilsignalsignalAll

Field Detail

delegateback to summary
private final Condition delegate
strongReferenceback to summary
private final Striped.WeakSafeReadWriteLock strongReference
Annotations
@SuppressWarnings:unused

Constructor Detail

WeakSafeConditionback to summary
pack-priv WeakSafeCondition(Condition delegate, Striped.WeakSafeReadWriteLock strongReference)

Method Detail

delegateback to summary
pack-priv Condition delegate()

Implements abstract com.google.common.util.concurrent.ForwardingCondition.delegate.

Annotations
@Override
com.google.common.util.concurrent back to summary

private final Class Striped.WeakSafeLock

extends ForwardingLock
Class Inheritance

Lock object that ensures a strong reference is retained to a specified object.

Field Summary

Modifier and TypeField and Description
private final Lock
private final Striped.WeakSafeReadWriteLock

Constructor Summary

AccessConstructor and Description
pack-priv
WeakSafeLock(Lock delegate, Striped.WeakSafeReadWriteLock strongReference)

Method Summary

Modifier and TypeMethod and Description
pack-priv Lock
public Condition
newCondition()

Overrides com.google.common.util.concurrent.ForwardingLock.newCondition.

Implements java.util.concurrent.locks.Lock.newCondition.

Returns a new Condition instance that is bound to this Lock instance.
Inherited from com.google.common.util.concurrent.ForwardingLock:
locklockInterruptiblytryLocktryLockunlock

Field Detail

delegateback to summary
private final Lock delegate
strongReferenceback to summary
private final Striped.WeakSafeReadWriteLock strongReference
Annotations
@SuppressWarnings:unused

Constructor Detail

WeakSafeLockback to summary
pack-priv WeakSafeLock(Lock delegate, Striped.WeakSafeReadWriteLock strongReference)

Method Detail

delegateback to summary
pack-priv Lock delegate()

Implements abstract com.google.common.util.concurrent.ForwardingLock.delegate.

Annotations
@Override
newConditionback to summary
public Condition newCondition()

Overrides com.google.common.util.concurrent.ForwardingLock.newCondition.

Implements java.util.concurrent.locks.Lock.newCondition.

Doc from java.util.concurrent.locks.Lock.newCondition.

Returns a new Condition instance that is bound to this Lock instance.

Before waiting on the condition the lock must be held by the current thread. A call to Condition#await() will atomically release the lock before waiting and re-acquire the lock before the wait returns.

Implementation Considerations

The exact operation of the Condition instance depends on the Lock implementation and must be documented by that implementation.

Returns:Condition

A new Condition instance for this Lock instance

Annotations
@Override
com.google.common.util.concurrent back to summary

private final Class Striped.WeakSafeReadWriteLock

extends Object
implements ReadWriteLock
Class Inheritance
  • java.lang.Object
  • com.google.common.util.concurrent.Striped.WeakSafeReadWriteLock
All Implemented Interfaces
java.util.concurrent.locks.ReadWriteLock

ReadWriteLock implementation whose read and write locks retain a reference back to this lock. Otherwise, a reference to just the read lock or just the write lock would not suffice to ensure the ReadWriteLock is retained.

Field Summary

Modifier and TypeField and Description
private final ReadWriteLock

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Lock
readLock()

Implements java.util.concurrent.locks.ReadWriteLock.readLock.

Returns the lock used for reading.
public Lock
writeLock()

Implements java.util.concurrent.locks.ReadWriteLock.writeLock.

Returns the lock used for writing.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final ReadWriteLock delegate

Constructor Detail

WeakSafeReadWriteLockback to summary
pack-priv WeakSafeReadWriteLock()

Method Detail

readLockback to summary
public Lock readLock()

Implements java.util.concurrent.locks.ReadWriteLock.readLock.

Doc from java.util.concurrent.locks.ReadWriteLock.readLock.

Returns the lock used for reading.

Returns:Lock

the lock used for reading

Annotations
@Override
writeLockback to summary
public Lock writeLock()

Implements java.util.concurrent.locks.ReadWriteLock.writeLock.

Doc from java.util.concurrent.locks.ReadWriteLock.writeLock.

Returns the lock used for writing.

Returns:Lock

the lock used for writing

Annotations
@Override