3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-11 00:23:25 +00:00

Re-added context creation locks in the Java API. Relates to #819.

This commit is contained in:
Christoph M. Wintersteiger 2016-12-01 23:16:15 +00:00
parent dedae29300
commit f1a704484b

View file

@ -31,14 +31,18 @@ public class Context implements AutoCloseable {
static final Object creation_lock = new Object();
public Context () {
synchronized (creation_lock) {
m_ctx = Native.mkContextRc(0);
init();
}
}
protected Context (long m_ctx) {
synchronized (creation_lock) {
this.m_ctx = m_ctx;
init();
}
}
/**
@ -59,6 +63,7 @@ public class Context implements AutoCloseable {
* module parameters. For this purpose we should now use {@code Global.setParameter}
**/
public Context(Map<String, String> settings) {
synchronized (creation_lock) {
long cfg = Native.mkConfig();
for (Map.Entry<String, String> kv : settings.entrySet()) {
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
@ -67,6 +72,7 @@ public class Context implements AutoCloseable {
Native.delConfig(cfg);
init();
}
}
private void init() {
setPrintMode(Z3_ast_print_mode.Z3_PRINT_SMTLIB2_COMPLIANT);
@ -4038,6 +4044,8 @@ public class Context implements AutoCloseable {
m_realSort = null;
m_stringSort = null;
synchronized (creation_lock) {
Native.delContext(m_ctx);
}
}
}