Libraryless. Compilation Failed (15525L/108K).
1 | !7 |
2 | |
3 | sclass ORef { |
4 | S globalID = aGlobalID(); |
5 | WeakReference ref; |
6 | new Set<S> forMachines; |
7 | long created = now(), lastAccessed; |
8 | } |
9 | |
10 | module ObjectReferences > DynObjectTable<ORef> { |
11 | transient Map<S, ORef> byGlobalID = synchroMap(); |
12 | transient Map<O, ORef> byObject = weakIdentityHashMap(); |
13 | |
14 | start { |
15 | dontPersist(); |
16 | itemToMap = func(ORef r) -> Map { |
17 | O o = getWeakRef(r.ref); |
18 | ret litorderedmap( |
19 | "Global ID" := r.globalID, |
20 | "Type" := o == null ? "gone" : className(o), |
21 | "Last Accessed" := formatLocalDateWithSeconds(r.lastAccessed), |
22 | "For Machines" := joinWithComma(r.forMachines)); |
23 | }; |
24 | } |
25 | |
26 | O _getReloadData() { ret data; } |
27 | void _setReloadData(L data) { addAll(this.data, map(data, func(O o) -> ORef { shallowCloneToClass(ORef, o) })); } |
28 | |
29 | // API |
30 | |
31 | // returns global ID |
32 | S addReferencedObject(O object, S forMachine) { |
33 | ORef r; |
34 | bool isNew; |
35 | { |
36 | lock lock; |
37 | r = byObject.get(object); |
38 | isNew = r == null; |
39 | if (isNew) { |
40 | r = new ORef; |
41 | r.ref = weakRef(object); |
42 | byGlobalID.put(r.globalID, r); |
43 | byObject.put(object, r); |
44 | } |
45 | r.lastAccessed = now(); |
46 | r.forMachines.add(forMachine); |
47 | } |
48 | if (isNew) add(r); |
49 | ret r.globalID; |
50 | } |
51 | |
52 | O getReferencedObject(S globalID) { |
53 | ORef r = byGlobalID.get(globalID); |
54 | ret r == null ? null : r.ref!; |
55 | } |
56 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020421 |
Snippet name: | Object References (e.g. Kept For Other Machines) |
Eternal ID of this version: | #1020421/14 |
Text MD5: | 8d710bfa4f7cf879d5b640e23be29261 |
Transpilation MD5: | e24cced520394fb353b0fe1f0076db01 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-21 15:42:30 |
Source code size: | 1444 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 357 / 929 |
Version history: | 13 change(s) |
Referenced in: | [show references] |