imglib / imglib2-cache

Cache interfaces and java.lang.ref based implementation.
Other
6 stars 4 forks source link

Add IoSync.shutdown method #13

Closed hanslovsky closed 5 years ago

hanslovsky commented 5 years ago

Also add IoSync as member to DiskCachedCellImg so it can be shutdown as well.

Fixes #12

Fun fact: I was unable to create a Writer[] array (Generic array creation error) and was very confused by it. Now I understand that it is because it's an inner class of IoSync, which is generic and thus, Writer is generic, as well.

I tested with this small method:

final DiskCachedCellImgFactory<UnsignedByteType> fac = new DiskCachedCellImgFactory<>(new UnsignedByteType());
DiskCachedCellImg<UnsignedByteType, ?> img = fac.create(10, 20, 30);

final boolean shutdownAfterUse = true;

while (true) {
    Thread.sleep(2000);
    if (shutdownAfterUse)
        img.shutdown();
    img = fac.create(10, 20, 30);
}

visual vm screenshots

This adds the IoSync as a member to the DiskCachedCellImg and breaks the interface of the constructor.

hanslovsky commented 5 years ago

We are currently evaluating this on a development branch (saalfeldlab/paintera#316) and it looks like this PR would solve our issues. What are your thoughts on the test case @tpietzsch?

tpietzsch commented 5 years ago

I'm releasing imglib2-cache 1.0.0-beta-13 with the merged PR

hanslovsky commented 5 years ago

Thanks a lot, very much appreciated!!