|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.atlassian.util.concurrent.ManagedLocks
public class ManagedLocks
Static factory for producing ManagedLock
and ManagedLock.ReadWrite
instances. Also contains factory methods for getting striping functions for
these as well.
All Parameters and returns values do no allow nulls. All supplied
functions
should not allow null values are permit null
returns.
Several methods take stripe functions. These functions should return the same
value for the life of their input, i.e. they should be based on immutable
properties of the input value - otherwise the stripe function might point to
a different lock depending on the state of the input. Whatever they return
will be used as a map key, so it should be a good candidate for a map key,
i.e. correctly implement Object.hashCode()
and
Object.equals(Object)
and be immutable.
Method Summary | ||
---|---|---|
static ManagedLock |
manage(java.util.concurrent.locks.Lock lock)
Get a ManagedLock that manages the supplied Lock . |
|
static ManagedLock.ReadWrite |
manageReadWrite(java.util.concurrent.locks.ReadWriteLock lock)
Get a ManagedLock.ReadWrite that manages the supplied
ReadWriteLock . |
|
static ManagedLock |
newManagedLock()
Get a ManagedLock that manages a ReentrantLock . |
|
static
|
weakManagedLockFactory()
Convenience method that calls weakManagedLockFactory(Function) using the
identity function for striping, essentially
meaning that unique input will have its own lock. |
|
static
|
weakManagedLockFactory(Function<T,D> stripeFunction)
Convenience method that simply calls weakManagedLockFactory(Function, Supplier) with the
default lock factory . |
|
static
|
weakManagedLockFactory(Function<T,D> stripeFunction,
Supplier<java.util.concurrent.locks.Lock> lockFactory)
Create a Function for resolving managed locks
. |
|
static
|
weakReadWriteManagedLockFactory()
A convenience method for calling weakReadWriteManagedLockFactory(Function) that uses the
identity function for striping, essentially
meaning that unique input will have its own lock. |
|
static
|
weakReadWriteManagedLockFactory(Function<T,D> stripeFunction)
A convenience method for calling weakReadWriteManagedLockFactory(Function, Supplier) that uses
default locks |
|
static
|
weakReadWriteManagedLockFactory(Function<T,D> stripeFunction,
Supplier<java.util.concurrent.locks.ReadWriteLock> lockFactory)
Create a Function for resolving managed read-write locks . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
@NotNull public static ManagedLock manage(@NotNull java.util.concurrent.locks.Lock lock)
ManagedLock
that manages the supplied Lock
.
lock
- the lock to use.
@NotNull public static ManagedLock newManagedLock()
ManagedLock
that manages a ReentrantLock
.
@NotNull public static ManagedLock.ReadWrite manageReadWrite(@NotNull java.util.concurrent.locks.ReadWriteLock lock)
ManagedLock.ReadWrite
that manages the supplied
ReadWriteLock
.
lock
- the lock to use.
@NotNull public static <T,D> Function<T,ManagedLock> weakManagedLockFactory(@NotNull Function<T,D> stripeFunction, @NotNull Supplier<java.util.concurrent.locks.Lock> lockFactory)
Function
for resolving managed locks
. The particular lock is resolved using a striping Function
that
is used 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. The locks are
stored using weak references so infrequently accessed locks should not
use excess memory.
T
- the type of the thing used to look up locksD
- the type used to map lock instances, should be a good map keystripeFunction
- to convert the input to the thing used to look up
the individual lockslockFactory
- the factory for creating the individual locks
Function
that provides ManagedLock
instances that stores created instances with weak references.@NotNull public static <T,D> Function<T,ManagedLock> weakManagedLockFactory(@NotNull Function<T,D> stripeFunction)
weakManagedLockFactory(Function, Supplier)
with the
default lock factory
.
T
- the type of the thing used to look up locksD
- the type used to map lock instances, should be a good map keystripeFunction
- to convert Ts to Ds.weakManagedLockFactory(Function, Supplier)
@NotNull public static <T> Function<T,ManagedLock> weakManagedLockFactory()
weakManagedLockFactory(Function)
using the
identity function
for striping, essentially
meaning that unique input will have its own lock.
T
- the type of the thing used to look up locksweakManagedLockFactory(Function, Supplier)
@NotNull public static <T,D> Function<T,ManagedLock.ReadWrite> weakReadWriteManagedLockFactory(@NotNull Function<T,D> stripeFunction, @NotNull Supplier<java.util.concurrent.locks.ReadWriteLock> lockFactory)
Function
for resolving managed read-write locks
. The particular lock is resolved using a
striping Function
that is used 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. The locks are stored using weak references so
infrequently accessed locks should not use excess memory.
T
- the type of the thing used to look up locksD
- the type used to map lock instances, should be a good map keystripeFunction
- to convert the input to the thing used to look up
the individual lockslockFactory
- the factory for creating the individual locks
Function
that provides
ManagedLock.ReadWrite
instances that stores created instances
with weak references.@NotNull public static <T,D> Function<T,ManagedLock.ReadWrite> weakReadWriteManagedLockFactory(Function<T,D> stripeFunction)
weakReadWriteManagedLockFactory(Function, Supplier)
that uses
default locks
T
- the type of the thing used to look up locksD
- the type used to map lock instances, should be a good map keystripeFunction
-
Function
that provides
ManagedLock.ReadWrite
instances that stores created instances
with weak references.@NotNull public static <T> Function<T,ManagedLock.ReadWrite> weakReadWriteManagedLockFactory()
weakReadWriteManagedLockFactory(Function)
that uses the
identity function
for striping, essentially
meaning that unique input will have its own lock.
T
- the type of the thing used to look up locks
Function
that provides the appropriate
ManagedLock.ReadWrite
for the argument ManagedLock.ReadWrite
instances that stores created instances with weak references.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |