File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,17 @@ private static synchronized boolean deleteIfEmpty(MasterCleaner caller) {
129
129
return caller .cleaners .isEmpty ();
130
130
}
131
131
132
+ /* The lifecycle of a Cleaner instance consists of four phases:
133
+ * 1. New instances are contained in Cleaner.INSTANCES and added to a MasterCleaner.cleaners set.
134
+ * 2. At some point, the master cleaner takes control of the instance by removing it
135
+ * from Cleaner.INSTANCES and MasterCleaner.cleaners, and then adding it to its
136
+ * referencedCleaners and watchedCleaners sets. Note that while it is no longer
137
+ * in Cleaner.INSTANCES, a thread may still be holding a reference to it.
138
+ * 3. Possibly some time later, the last reference to the cleaner instance is dropped and
139
+ * it is GC'd. It is then also removed from referencedCleaners but remains in watchedCleaners.
140
+ * 4. The master cleaner continues to monitor the watchedCleaners until they are empty and no
141
+ * longer referenced. At that point they are also removed from watchedCleaners.
142
+ */
132
143
final Set <Cleaner > cleaners = Collections .synchronizedSet (new HashSet <>());
133
144
final Set <CleanerImpl > referencedCleaners = new HashSet <>();
134
145
final Set <CleanerImpl > watchedCleaners = new HashSet <>();
You can’t perform that action at this time.
0 commit comments