org.jetbrains.jet.storage
Class LockBasedStorageManager

java.lang.Object
  extended by org.jetbrains.jet.storage.LockBasedStorageManager
All Implemented Interfaces:
StorageManager
Direct Known Subclasses:
LockBasedLazyResolveStorageManager

public class LockBasedStorageManager
extends java.lang.Object
implements StorageManager


Field Summary
protected  java.util.concurrent.locks.Lock lock
           
static StorageManager NO_LOCKS
           
 
Constructor Summary
LockBasedStorageManager()
           
 
Method Summary
<T> T
compute(jet.Function0<T> computable)
           
<T> NotNullLazyValue<T>
createLazyValue(jet.Function0<T> computable)
           
<T> NotNullLazyValue<T>
createLazyValueWithPostCompute(jet.Function0<T> computable, jet.Function1<java.lang.Boolean,T> onRecursiveCall, jet.Function1<T,jet.Unit> postCompute)
           
<K,V> MemoizedFunctionToNotNull<K,V>
createMemoizedFunction(jet.Function1<K,V> compute)
          Given a function compute: K -> V create a memoized version of it that computes a value only once for each key
protected
<K,V> MemoizedFunctionToNotNull<K,V>
createMemoizedFunction(jet.Function1<K,V> compute, java.util.concurrent.ConcurrentMap<K,java.lang.Object> map)
           
<K,V> MemoizedFunctionToNullable<K,V>
createMemoizedFunctionWithNullableValues(jet.Function1<K,V> compute)
           
protected
<K,V> MemoizedFunctionToNullable<K,V>
createMemoizedFunctionWithNullableValues(jet.Function1<K,V> compute, java.util.concurrent.ConcurrentMap<K,java.lang.Object> map)
           
<T> NullableLazyValue<T>
createNullableLazyValue(jet.Function0<T> computable)
           
<T> NullableLazyValue<T>
createNullableLazyValueWithPostCompute(jet.Function0<T> computable, jet.Function1<T,jet.Unit> postCompute)
          postCompute is called after the value is computed, but before any other thread sees it (the current thread may see it in between)
<T> NotNullLazyValue<T>
createRecursionTolerantLazyValue(jet.Function0<T> computable, T onRecursiveCall)
           
<T> NullableLazyValue<T>
createRecursionTolerantNullableLazyValue(jet.Function0<T> computable, T onRecursiveCall)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_LOCKS

public static final StorageManager NO_LOCKS

lock

protected final java.util.concurrent.locks.Lock lock
Constructor Detail

LockBasedStorageManager

public LockBasedStorageManager()
Method Detail

createMemoizedFunction

@NotNull
public <K,V> MemoizedFunctionToNotNull<K,V> createMemoizedFunction(@NotNull
                                                                           jet.Function1<K,V> compute)
Description copied from interface: StorageManager
Given a function compute: K -> V create a memoized version of it that computes a value only once for each key

Specified by:
createMemoizedFunction in interface StorageManager
Parameters:
compute - the function to be memoized

createMemoizedFunction

@NotNull
protected <K,V> MemoizedFunctionToNotNull<K,V> createMemoizedFunction(@NotNull
                                                                              jet.Function1<K,V> compute,
                                                                              @NotNull
                                                                              java.util.concurrent.ConcurrentMap<K,java.lang.Object> map)

createMemoizedFunctionWithNullableValues

@NotNull
public <K,V> MemoizedFunctionToNullable<K,V> createMemoizedFunctionWithNullableValues(@NotNull
                                                                                              jet.Function1<K,V> compute)
Specified by:
createMemoizedFunctionWithNullableValues in interface StorageManager

createMemoizedFunctionWithNullableValues

@NotNull
protected <K,V> MemoizedFunctionToNullable<K,V> createMemoizedFunctionWithNullableValues(@NotNull
                                                                                                 jet.Function1<K,V> compute,
                                                                                                 @NotNull
                                                                                                 java.util.concurrent.ConcurrentMap<K,java.lang.Object> map)

createLazyValue

@NotNull
public <T> NotNullLazyValue<T> createLazyValue(@NotNull
                                                       jet.Function0<T> computable)
Specified by:
createLazyValue in interface StorageManager

createRecursionTolerantLazyValue

@NotNull
public <T> NotNullLazyValue<T> createRecursionTolerantLazyValue(@NotNull
                                                                        jet.Function0<T> computable,
                                                                        @NotNull
                                                                        T onRecursiveCall)
Specified by:
createRecursionTolerantLazyValue in interface StorageManager

createLazyValueWithPostCompute

@NotNull
public <T> NotNullLazyValue<T> createLazyValueWithPostCompute(@NotNull
                                                                      jet.Function0<T> computable,
                                                                      jet.Function1<java.lang.Boolean,T> onRecursiveCall,
                                                                      @NotNull
                                                                      jet.Function1<T,jet.Unit> postCompute)
Specified by:
createLazyValueWithPostCompute in interface StorageManager
onRecursiveCall - is called if the computation calls itself recursively. The parameter to it is true for the first call, false otherwise. If onRecursiveCall is null, an exception will be thrown on a recursive call, otherwise it's executed and its result is returned
postCompute - is called after the value is computed, but before any other thread sees it

createNullableLazyValue

@NotNull
public <T> NullableLazyValue<T> createNullableLazyValue(@NotNull
                                                                jet.Function0<T> computable)
Specified by:
createNullableLazyValue in interface StorageManager

createRecursionTolerantNullableLazyValue

@NotNull
public <T> NullableLazyValue<T> createRecursionTolerantNullableLazyValue(@NotNull
                                                                                 jet.Function0<T> computable,
                                                                                 T onRecursiveCall)
Specified by:
createRecursionTolerantNullableLazyValue in interface StorageManager

createNullableLazyValueWithPostCompute

@NotNull
public <T> NullableLazyValue<T> createNullableLazyValueWithPostCompute(@NotNull
                                                                               jet.Function0<T> computable,
                                                                               @NotNull
                                                                               jet.Function1<T,jet.Unit> postCompute)
Description copied from interface: StorageManager
postCompute is called after the value is computed, but before any other thread sees it (the current thread may see it in between)

Specified by:
createNullableLazyValueWithPostCompute in interface StorageManager

compute

public <T> T compute(@NotNull
                     jet.Function0<T> computable)
Specified by:
compute in interface StorageManager