mirror of
https://github.com/Z3Prover/z3
synced 2026-02-12 03:44:07 +00:00
Improved Java phantom references (#7131)
* Reworked phantom reference handling. - Replaced IDecRefQueue with a new Z3ReferenceQueue class - Z3ReferenceQueue manages custom subclasses of phantom references in a doubly-linked list - Replaced all subclasses of IDecRefQueue with subclasses of Z3ReferenceQueue.Reference. These custom reference classes are embedded in the class they reference count. - Context now owns a single Z3ReferenceQueue for all types of references. * Made Statistics.Entry a static subclass * Made Context.close idempotent (as recommended) * Update CMakeLists.txt for building the Java API. * Updated CMakeLists.txt again. * Use correct SuppressWarning annotation to silence the compiler * Formatting
This commit is contained in:
parent
f7691d34fd
commit
a3d00ce356
41 changed files with 448 additions and 805 deletions
|
|
@ -17,6 +17,8 @@ Notes:
|
|||
|
||||
package com.microsoft.z3;
|
||||
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
|
||||
/**
|
||||
* Tactics are the basic building block for creating custom solvers for specific
|
||||
* problem domains. The complete list of tactics may be obtained using
|
||||
|
|
@ -98,6 +100,19 @@ public class Tactic extends Z3Object {
|
|||
|
||||
@Override
|
||||
void addToReferenceQueue() {
|
||||
getContext().getTacticDRQ().storeReference(getContext(), this);
|
||||
//getContext().getTacticDRQ().storeReference(getContext(), this);
|
||||
getContext().getReferenceQueue().storeReference(this, TacticRef::new);
|
||||
}
|
||||
|
||||
private static class TacticRef extends Z3ReferenceQueue.Reference<Tactic> {
|
||||
|
||||
private TacticRef(Tactic referent, ReferenceQueue<Z3Object> q) {
|
||||
super(referent, q);
|
||||
}
|
||||
|
||||
@Override
|
||||
void decRef(Context ctx, long z3Obj) {
|
||||
Native.tacticDecRef(ctx.nCtx(), z3Obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue