com.atlassian.util.concurrent
Interface ManagedLock


public interface ManagedLock

ManagedLock allows callables, runnables and suppliers to be run under a lock that is resolved against an input object.

Since:
0.0.7

Nested Class Summary
static interface ManagedLock.ReadWrite
          Maintains two managed locks that internally use the same read/write locks
 
Method Summary
<R> R
withLock(java.util.concurrent.Callable<R> callable)
          Execute the supplied Callable under a lock determined by the descriptor.
 void withLock(java.lang.Runnable runnable)
          Execute the supplied Runnable under a lock determined by the descriptor.
<R> R
withLock(Supplier<R> supplier)
          Execute the supplied Supplier under a lock determined by the descriptor.
 

Method Detail

withLock

<R> R withLock(@NotNull
               java.util.concurrent.Callable<R> callable)
           throws java.lang.Exception
Execute the supplied Callable under a lock determined by the descriptor.

Type Parameters:
R - the result type
Parameters:
callable - the operation to perform under lock
Returns:
whatever the supplied Callable returns
Throws:
java.lang.Exception - if the supplied Callable throws an exception

withLock

<R> R withLock(@NotNull
               Supplier<R> supplier)
Execute the supplied Supplier under a lock determined by the descriptor.

Unlike withLock(Callable) this version returns a result and does not declare a checked exception.

Type Parameters:
R - the result type
Parameters:
supplier - the operation to perform under lock
Returns:
whatever the supplied Callable returns

withLock

void withLock(@NotNull
              java.lang.Runnable runnable)
Execute the supplied Runnable under a lock determined by the descriptor.

Parameters:
runnable - the operation to perform under lock


Copyright © 2009 Atlassian. All Rights Reserved.