Assert ViewStreamDatabase.instance is only created once

The instance must be initialized via ViewStreamDatabase.SetGlobalInstance
This commit is contained in:
John Colvin committed 2024-10-14 17:21:46 +00:00
1 parent e396ebb181
commit 8a2dea53e6
1 file changed
+8 -16
@@ -35,20 +35,10 @@ namespace BCG {
public static ViewStreamDatabase instance {
get {
if (mySelf == null || mySelf.myIsDisposed)
lock (myInstanceLockObject) {
if (mySelf == null || mySelf.myIsDisposed) {
mySelf = new ViewStreamDatabase();
}
}
return mySelf;
}
set {
lock (myInstanceLockObject) {
if (mySelf != null)
mySelf.mySubscriberCore.Dispose();
mySelf = value;
}
var rv = mySelf;
Log.notnull(rv);
Log.assert(!rv.myIsDisposed);
return rv;
}
}
@@ -187,8 +177,10 @@ namespace BCG {
}
internal static void SetGlobalInstance(ViewStreamDatabase vsd) {
Log.isnull(mySelf);
mySelf = vsd;
lock (myInstanceLockObject) {
Log.isnull(mySelf);
mySelf = vsd;
}
}
private List<PendingAddRemoveWorker> _pending_worker_ops = new List<PendingAddRemoveWorker>();