3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 11:25:51 +00:00
This commit is contained in:
Christoph M. Wintersteiger 2015-10-14 13:59:20 +01:00
commit 58d3329190
6 changed files with 73 additions and 43 deletions

View file

@ -18,6 +18,7 @@ Notes:
package com.microsoft.z3;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import com.microsoft.z3.enumerations.Z3_ast_print_mode;
@ -3766,29 +3767,35 @@ public class Context extends IDisposable
return m_Optimize_DRQ;
}
protected long m_refCount = 0;
protected AtomicInteger m_refCount = new AtomicInteger(0);
/**
* Finalizer.
* @throws Throwable
**/
protected void finalize()
protected void finalize() throws Throwable
{
dispose();
if (m_refCount == 0)
{
try
try {
dispose();
if (m_refCount.get() == 0)
{
Native.delContext(m_ctx);
} catch (Z3Exception e)
{
// OK.
}
m_ctx = 0;
}
/*
else
CMW: re-queue the finalizer? */
try
{
Native.delContext(m_ctx);
} catch (Z3Exception e)
{
// OK.
}
m_ctx = 0;
}
}
catch (Throwable t) {
throw t;
}
finally {
super.finalize();
}
}
/**