Skip to content

Commit 1f83b7d

Browse files
committed
Context: Adjust the allocation api to use the hashcode for identification.
1 parent 2cd0165 commit 1f83b7d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class Context {
3434
private static final ConcurrentHashMap<String, List<Ast>> import_cache = new ConcurrentHashMap<>();
3535
private static final ExecutorService threadPool = Executors.newVirtualThreadPerTaskExecutor();
3636
public static final ConcurrentMap<String, Future<PiccodeValue>> futureMap = new ConcurrentHashMap<>();
37-
public static final ConcurrentMap<String, Object> objectPool = new ConcurrentHashMap<>();
37+
public static final ConcurrentMap<Integer, Object> objectPool = new ConcurrentHashMap<>();
3838

3939
public Context() {
4040
call_frames = new Stack<>();
@@ -95,11 +95,11 @@ public static void removeFuture(String uuid) {
9595
futureMap.remove(uuid);
9696
}
9797

98-
public static String allocate(Object obj) {
98+
public static int allocate(Object obj) {
9999
synchronized (Context.class) {
100+
var id = obj.hashCode();
100101
var size = objectPool.size();
101102
var name = String.format("Thread@%d", size);
102-
var id = name + UUID.randomUUID().toString();
103103
objectPool.put(id, obj);
104104
return id;
105105
}

0 commit comments

Comments
 (0)