3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 17:45:32 +00:00

Do not lock on context creation and deletion.

This commit is contained in:
George Karpenkov 2016-06-13 12:09:34 +02:00
parent 22ffd65d1e
commit 27aa37946e

View file

@ -31,12 +31,7 @@ public class Context implements AutoCloseable {
static final Object creation_lock = new Object();
public static Context mkContext() {
long m_ctx;
synchronized (creation_lock) {
m_ctx = Native.mkContextRc(0);
// TODO: then adding settings will not be under the lock.
}
return new Context(m_ctx);
return new Context(Native.mkContextRc(0));
}
@ -59,14 +54,11 @@ public class Context implements AutoCloseable {
**/
public static Context mkContext(Map<String, String> settings)
{
long m_ctx;
synchronized (creation_lock) {
long cfg = Native.mkConfig();
for (Map.Entry<String, String> kv : settings.entrySet())
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
m_ctx = Native.mkContextRc(cfg);
Native.delConfig(cfg);
}
long cfg = Native.mkConfig();
for (Map.Entry<String, String> kv : settings.entrySet())
Native.setParamValue(cfg, kv.getKey(), kv.getValue());
long m_ctx = Native.mkContextRc(cfg);
Native.delConfig(cfg);
return new Context(m_ctx);
}
@ -4047,8 +4039,6 @@ public class Context implements AutoCloseable {
m_realSort = null;
m_stringSort = null;
synchronized (creation_lock) {
Native.delContext(m_ctx);
}
Native.delContext(m_ctx);
}
}