Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add an explanatory comment to the top of _ANIdentifiedResourceSet

It's difficult to envision what the class is doing without it.
  • Loading branch information...
commit ffc9174b933e1b6aedcb51683d50c15cdb398f1f 1 parent c29e0a7
Brent Royal-Gordon authored
Showing with 24 additions and 1 deletion.
  1. +24 −1 _ANIdentifiedResourceSet.m
View
25 _ANIdentifiedResourceSet.m
@@ -8,7 +8,8 @@
#import "_ANIdentifiedResourceSet.h"
-// Basically just a safer version of +[NSValue valueWithNonretainedObject:]
+// Basically just a zeroing weak version of +[NSValue valueWithNonretainedObject:]
+
@interface _ANWeakReference : NSObject
+ (id)weakReferenceWithReferent:(id)referent;
@@ -18,6 +19,28 @@ - (id)initWithReferent:(id)referent;
@end
+//
+// We construct what amounts to a weakly-referencing mutable set from strong mutable dictionaries and weak reference objects.
+//
+// The resources table is structured like so:
+// @{
+// @"ANPost": @{
+// @1: [_ANWeakReference weakReferenceWithReferent:<ANPost with ID 1>],
+// @2: [_ANWeakReference weakReferenceWithReferent:<ANPost with ID 2>],
+// @3: [_ANWeakReference weakReferenceWithReferent:nil from __weak reference to now-dead object],
+// ...
+// },
+// @"ANUser": @{
+// ...
+// },
+// ...
+// }
+//
+// Because clients of _ANIdentifiedResourceSet only ever see the referents, not the weak references, deallocated resources appear to have been deleted from the table, even though there are still nil'ed entries in the weak reference table for them.
+//
+// A future version could occasionally purge these dead entries, but we are not currently doing that.
+//
+
@interface _ANIdentifiedResourceSet ()
@property (strong,nonatomic) NSMutableDictionary * resources;
Please sign in to comment.
Something went wrong with that request. Please try again.