Class Clutch.Pack
java.lang.Object
org.cojen.tupl.util.Latch
org.cojen.tupl.util.Clutch.Pack
- Enclosing class:
Clutch
Sharable object for supporting contended clutches. Memory overhead (in bytes) is
proportional to
(number of slots) * (number of cores). The number of slots
should be at least 16, to minimize cache line contention. As a convenience, this class
also extends the Latch class, but the latching features aren't used here.-
Nested Class Summary
Nested classes/interfaces inherited from class Latch
Latch.ConditionModifier and TypeClassDescriptionstatic classManages a queue of waiting threads, associated with aLatchinstance. -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class Latch
acquireExclusive, acquireExclusiveInterruptibly, acquireShared, acquireSharedInterruptibly, acquireSharedUncontended, acquireSharedUncontendedNanos, downgrade, hasQueuedThreads, release, releaseEither, releaseExclusive, releaseShared, toString, tryAcquireExclusive, tryAcquireExclusiveNanos, tryAcquireShared, tryAcquireSharedNanos, tryUpgrade, uponExclusiveModifier and TypeMethodDescriptionvoidAcquire the exclusive latch, barging ahead of any waiting threads if possible.voidAcquire the exclusive latch, aborting if interrupted.voidAcquire a shared latch, barging ahead of any waiting threads if possible.voidAcquire a shared latch, aborting if interrupted.booleanLike tryAcquireShared, except blocks if an exclusive latch is held.intacquireSharedUncontendedNanos(long nanosTimeout) Like tryAcquireSharedNanos, except blocks if an exclusive latch is held.final voidDowngrade the held exclusive latch into a shared latch.final booleanfinal voidrelease(boolean exclusive) Convenience method, which releases the held exclusive or shared latch.final voidReleases an exclusive or shared latch.final voidRelease the held exclusive latch.voidRelease a held shared latch.toString()booleanTry to acquire the exclusive latch, barging ahead of any waiting threads if possible.booleantryAcquireExclusiveNanos(long nanosTimeout) Attempt to acquire the exclusive latch, aborting if interrupted.booleanTry to acquire a shared latch, barging ahead of any waiting threads if possible.booleantryAcquireSharedNanos(long nanosTimeout) Attempt to acquire a shared latch, aborting if interrupted.booleanAttempt to upgrade a held shared latch into an exclusive latch.voiduponExclusive(Runnable cont) Invokes the given continuation upon the latch being acquired exclusively.
-
Constructor Details
-
Pack
public Pack(int numSlots) - Parameters:
numSlots- amount of contended clutches that this pack can support
-
Pack
public Pack(int numSlots, int cores) - Parameters:
numSlots- amount of contended clutches that this pack can supportcores- must be at least 1 CPU core
-