!7 sclass ORef { S globalID = aGlobalID(); WeakReference ref; new Set forMachines; long created = now(), lastAccessed; } module ObjectReferences > DynObjectTable { transient Map byGlobalID = synchroMap(); transient Map byObject = weakIdentityHashMap(); start { dontPersist(); itemToMap = func(ORef r) -> Map { O o = getWeakRef(r.ref); ret litorderedmap( "Global ID" := r.globalID, "Type" := o == null ? "gone" : className(o), "Last Accessed" := formatLocalDateWithSeconds(r.lastAccessed), "For Machines" := joinWithComma(r.forMachines)); }; } // API // returns global ID S addReferencedObject(O object, S forMachine) { lock lock; ORef r = byObject.get(object); bool isNew = r == null; if (isNew) { r = new ORef; r.ref = weakRef(object); byGlobalID.put(r.globalID, r); byObject.put(object, r); } r.lastAccessed = now(); r.forMachines.add(forMachine); if (isNew) add(r); ret r.globalID; } O getReferencedObject(S globalID) { ORef r = byGlobalID.get(globalID); ret r == null ? null : r.ref!; } }