Skip to content
Snippets Groups Projects
Commit 40423592 authored by Tobias Pietzsch's avatar Tobias Pietzsch
Browse files

only a part of VolatileGlobalCellCache.createGlobal() needs to be synchronized

parent a72b7403
No related branches found
No related tags found
No related merge requests found
...@@ -407,20 +407,23 @@ public class VolatileGlobalCellCache< A extends VolatileAccess > implements Cach ...@@ -407,20 +407,23 @@ public class VolatileGlobalCellCache< A extends VolatileAccess > implements Cach
* *
* @return a cell with the specified coordinates. * @return a cell with the specified coordinates.
*/ */
public synchronized VolatileCell< A > createGlobal( final int[] cellDims, final long[] cellMin, final int timepoint, final int setup, final int level, final int index, final LoadingStrategy loadingStrategy ) public VolatileCell< A > createGlobal( final int[] cellDims, final long[] cellMin, final int timepoint, final int setup, final int level, final int index, final LoadingStrategy loadingStrategy )
{ {
final Key k = new Key( timepoint, setup, level, index ); final Key k = new Key( timepoint, setup, level, index );
Entry entry = null; Entry entry = null;
final Reference< Entry > ref = softReferenceCache.get( k ); synchronized ( softReferenceCache )
if ( ref != null )
entry = ref.get();
if ( entry == null )
{ {
final VolatileCell< A > cell = new VolatileCell< A >( cellDims, cellMin, loader.emptyArray( cellDims ) ); final Reference< Entry > ref = softReferenceCache.get( k );
entry = new Entry( k, cell ); if ( ref != null )
softReferenceCache.put( k, new WeakReference< Entry >( entry ) ); entry = ref.get();
if ( entry == null )
{
final VolatileCell< A > cell = new VolatileCell< A >( cellDims, cellMin, loader.emptyArray( cellDims ) );
entry = new Entry( k, cell );
softReferenceCache.put( k, new WeakReference< Entry >( entry ) );
}
} }
switch ( loadingStrategy ) switch ( loadingStrategy )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment