Skip to content

Commit c7263b2

Browse files
committed
Context: Resetting the context should allow clearing the import cache
1 parent 5580412 commit c7263b2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/main/java/org/piccode/rt/Context.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ public Context() {
4444
}
4545

4646
public void resetContext() {
47-
annotations.clear();
48-
threadContexts.clear();
49-
futureMap.clear();
50-
objectPool.clear();
51-
call_frames.clear();
47+
resetContext(false);
5248
}
5349

50+
public void resetContext(boolean removeImports) {
51+
synchronized (this) {
52+
annotations.clear();
53+
threadContexts.clear();
54+
futureMap.clear();
55+
objectPool.clear();
56+
call_frames.clear();
57+
if (removeImports) {
58+
import_cache.clear();
59+
}
60+
}
61+
}
62+
5463
public static int makeThreadContext(Context base) {
5564
int index = threadContexts.size();
5665
var context = new Context();
@@ -131,7 +140,7 @@ public static Object getObject(int id) {
131140
return objectPool.get(id);
132141
}
133142
}
134-
143+
135144
public static void removeObject(int id) {
136145
objectPool.remove(id);
137146
}

0 commit comments

Comments
 (0)