mirror of
https://github.com/Z3Prover/z3
synced 2025-06-19 20:33:38 +00:00
Dealt with some concurrency issues due to concurrent GC.
This commit is contained in:
parent
47ac5c0633
commit
5a45711f22
2 changed files with 5 additions and 5 deletions
|
@ -3646,7 +3646,7 @@ namespace Microsoft.Z3
|
||||||
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
|
internal Fixedpoint.DecRefQueue Fixedpoint_DRQ { get { Contract.Ensures(Contract.Result<Fixedpoint.DecRefQueue>() != null); return m_Fixedpoint_DRQ; } }
|
||||||
|
|
||||||
|
|
||||||
internal uint refCount = 0;
|
internal int refCount = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finalizer.
|
/// Finalizer.
|
||||||
|
|
|
@ -19,6 +19,7 @@ Notes:
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace Microsoft.Z3
|
namespace Microsoft.Z3
|
||||||
{
|
{
|
||||||
|
@ -50,8 +51,7 @@ namespace Microsoft.Z3
|
||||||
|
|
||||||
if (m_ctx != null)
|
if (m_ctx != null)
|
||||||
{
|
{
|
||||||
m_ctx.refCount--;
|
if (Interlocked.Decrement(ref m_ctx.refCount) == 0)
|
||||||
if (m_ctx.refCount == 0)
|
|
||||||
GC.ReRegisterForFinalize(m_ctx);
|
GC.ReRegisterForFinalize(m_ctx);
|
||||||
m_ctx = null;
|
m_ctx = null;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace Microsoft.Z3
|
||||||
{
|
{
|
||||||
Contract.Requires(ctx != null);
|
Contract.Requires(ctx != null);
|
||||||
|
|
||||||
ctx.refCount++;
|
Interlocked.Increment(ref ctx.refCount);
|
||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ namespace Microsoft.Z3
|
||||||
{
|
{
|
||||||
Contract.Requires(ctx != null);
|
Contract.Requires(ctx != null);
|
||||||
|
|
||||||
ctx.refCount++;
|
Interlocked.Increment(ref ctx.refCount);
|
||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
IncRef(obj);
|
IncRef(obj);
|
||||||
m_n_obj = obj;
|
m_n_obj = obj;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue