Mercurial > hg > truffle
diff truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java @ 22183:1421041175a7
Adding dispose() and TruffleLanguage.disposeContext to allow user request and languages explicitly free the resources
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Mon, 21 Sep 2015 14:05:33 +0200 |
parents | dc83cc1f94f2 |
children | 6380c7de0159 |
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java Mon Sep 21 13:11:41 2015 +0200 +++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/ImplicitExplicitExportTest.java Mon Sep 21 14:05:33 2015 +0200 @@ -36,8 +36,10 @@ import java.io.Reader; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.concurrent.Executors; import org.junit.After; import static org.junit.Assert.assertEquals; @@ -123,6 +125,8 @@ } private static final class Ctx { + static final Set<Ctx> disposed = new HashSet<>(); + final Map<String, String> explicit = new HashMap<>(); final Map<String, String> implicit = new HashMap<>(); final Env env; @@ -130,6 +134,10 @@ public Ctx(Env env) { this.env = env; } + + void dispose() { + disposed.add(this); + } } private abstract static class AbstractExportImportLanguage extends TruffleLanguage<Ctx> { @@ -143,6 +151,11 @@ } @Override + protected void disposeContext(Ctx context) { + context.dispose(); + } + + @Override protected CallTarget parse(Source code, Node context, String... argumentNames) throws IOException { if (code.getCode().startsWith("parse=")) { throw new IOException(code.getCode().substring(6));