Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/main/java/bdv/util/volatiles/CacheControlUnsafe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package bdv.util.volatiles;

import net.imglib2.cache.AbstractCache;
import net.imglib2.cache.volatiles.AbstractVolatileCache;

/**
*
* @author Philipp Hanslovsky
*
* This interface is used to expose controls of
* {@link AbstractVolatileCache volatile caches} and
* {@link AbstractCache caches}, e.g. in {@link VolatileViewData}.
* Methods in this interface may have implications and/or side-effects
* and should be used with caution/by callers who are aware of these.
*
*/
public interface CacheControlUnsafe
{

/**
* Invalidate all existing cache entries, e.g.
* {@link AbstractCache#invalidateAll() or
* {@link AbstractVolatileCache#invalidateAll()}}.
*/
public void invalidateAll();

}
18 changes: 18 additions & 0 deletions src/main/java/bdv/util/volatiles/VolatileViewData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.imglib2.RandomAccessible;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.Volatile;
import net.imglib2.cache.Cache;
import net.imglib2.cache.img.CachedCellImg;

/**
Expand All @@ -22,25 +23,30 @@
* corresponding volatile pixel type
*
* @author Tobias Pietzsch
* @author Philipp Hanslovsky
*/
public class VolatileViewData< T, V extends Volatile< T > >
{
private final RandomAccessible< V > img;

private final CacheControl cacheControl;

private final CacheControlUnsafe cacheControlUsnafe;

private final T type;

private final V volatileType;

public VolatileViewData(
final RandomAccessible< V > img,
final CacheControl cacheControl,
final CacheControlUnsafe cacheControlUsnafe,
final T type,
final V volatileType )
{
this.img = img;
this.cacheControl = cacheControl;
this.cacheControlUsnafe = cacheControlUsnafe;
this.type = type;
this.volatileType = volatileType;
}
Expand All @@ -67,6 +73,18 @@ public CacheControl getCacheControl()
return cacheControl;
}

/**
* Get the {@link CacheControlUnsafe} for the {@link CachedCellImg}(s) at the
* bottom of the view cascade.
*
* @return the {@link CacheControlUnsafe} for the {@link CachedCellImg}(s) at the
* bottom of the view cascade
*/
public CacheControlUnsafe getCacheControlUnsafe()
{
return this.cacheControlUsnafe;
}

/**
* Get the pixel type of the original image.
*
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/bdv/util/volatiles/VolatileViews.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* BigDataViewer while loading asynchronously.
*
* @author Tobias Pietzsch
* @author Philipp Hanslovsky
*/
public class VolatileViews
{
Expand Down Expand Up @@ -107,6 +108,7 @@ else if ( rai instanceof IntervalView )
return new VolatileViewData<>(
new IntervalView<>( sourceData.getImg(), view ),
sourceData.getCacheControl(),
sourceData.getCacheControlUnsafe(),
sourceData.getType(),
sourceData.getVolatileType() );
}
Expand All @@ -117,6 +119,7 @@ else if ( rai instanceof MixedTransformView )
return new VolatileViewData<>(
new MixedTransformView<>( sourceData.getImg(), view.getTransformToSource() ),
sourceData.getCacheControl(),
sourceData.getCacheControlUnsafe(),
sourceData.getType(),
sourceData.getVolatileType() );
}
Expand Down Expand Up @@ -147,7 +150,7 @@ private static < T extends NativeType< T >, V extends Volatile< T > & NativeType
@SuppressWarnings( "rawtypes" )
final VolatileCachedCellImg< V, ? > img = createVolatileCachedCellImg( grid, vtype, dirty, ( Cache ) cache, queue, hints );

return new VolatileViewData<>( img, queue, type, vtype );
return new VolatileViewData<>( img, queue, cache::invalidateAll, type, vtype );
}

private static < T extends NativeType< T >, A extends VolatileArrayDataAccess< A > > VolatileCachedCellImg< T, A > createVolatileCachedCellImg(
Expand Down