File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed
src/main/java/ch/epfl/biop/bdv/img Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 21
21
*/
22
22
package ch .epfl .biop .bdv .img ;
23
23
24
+ import bdv .cache .SharedQueue ;
24
25
import bdv .img .cache .VolatileGlobalCellCache ;
25
26
27
+ import java .lang .reflect .Field ;
28
+
26
29
public interface CacheControlOverride {
27
30
28
31
void setCacheControl (VolatileGlobalCellCache cache );
32
+
33
+ public static class Tools {
34
+ public static void shutdownCacheQueue (VolatileGlobalCellCache cache ) {
35
+ try {
36
+ Field queueField = VolatileGlobalCellCache .class .getDeclaredField (
37
+ "queue" );
38
+ queueField .setAccessible (true );
39
+ SharedQueue queue = (SharedQueue ) queueField .get (cache );
40
+ queue .shutdown (); // Kill the non-used thread
41
+ } catch (NoSuchFieldException e ) {
42
+ throw new RuntimeException (e );
43
+ } catch (IllegalAccessException e ) {
44
+ throw new RuntimeException (e );
45
+ }
46
+ }
47
+ }
29
48
}
Original file line number Diff line number Diff line change 35
35
36
36
import java .io .Closeable ;
37
37
import java .io .IOException ;
38
+ import java .lang .reflect .Field ;
38
39
import java .util .ArrayList ;
39
40
import java .util .HashMap ;
40
41
import java .util .List ;
@@ -230,6 +231,7 @@ public void close() {
230
231
231
232
@ Override
232
233
public void setCacheControl (VolatileGlobalCellCache cache ) {
234
+ CacheControlOverride .Tools .shutdownCacheQueue (this .cache );
233
235
this .cache .clearCache ();
234
236
this .cache = cache ;
235
237
}
Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ public VolatileGlobalCellCache getCacheControl() {
187
187
188
188
@ Override
189
189
public void setCacheControl (VolatileGlobalCellCache cache ) {
190
+ CacheControlOverride .Tools .shutdownCacheQueue (this .cache );
190
191
this .cache .clearCache ();
191
192
this .cache = cache ;
192
193
}
You can’t perform that action at this time.
0 commit comments