|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.atlassian.util.concurrent.LockManagers
public class LockManagers
Static factory for producing LockManager
instances.
Method Summary | ||
---|---|---|
static
|
weakLockManager(Function<T,D> stripeFunction)
Convenience method that simply calls weakLockManager(Function, int) with
a default initial capacity of 128. |
|
static
|
weakLockManager(Function<T,D> stripeFunction,
int initialCapacity)
The particular Lock is resolved using a Function that resolves to a
descriptor used to look up a Lock instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T,D> LockManager<T> weakLockManager(Function<T,D> stripeFunction)
weakLockManager(Function, int)
with
a default initial capacity of 128.
T
- the type of the thing used to look up locksD
- the type used to map lock instancesstripeFunction
- to convert Ts to Ds.weakLockManager(Function, int)
public static <T,D> LockManager<T> weakLockManager(Function<T,D> stripeFunction, int initialCapacity)
Lock
is resolved using a Function
that resolves to a
descriptor used to look up a Lock instance. This allows for a finite set of locks to be used
even if the set of T is essentially unbounded.
For instance:
LockManager<Identifiable, Integer> manager = LockManagers.weakLockManager(new Function<Identifiable, Integer>() { Integer get(Identifiable thing) { return thing.getId() % 16; } };uses only 16 possible locks as the function returns the modulo 16 of the thing's id.
T
- the type of the thing used to look up locksD
- the type used to map lock instancesstripeFunction
- to convert Ts to Ds.initialCapacity
- the initial capacity of the internal map.
LockManager
instance that stores created Lock
instances with
weak references.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |