File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,23 @@ void background_callback_reset() {
108
108
}
109
109
110
110
void background_callback_gc_collect (void ) {
111
+ // We don't enter the callback critical section here. We rely on
112
+ // gc_collect_ptr _NOT_ entering background callbacks, so it is not
113
+ // possible for the list to be cleared.
114
+ //
115
+ // However, it is possible for the list to be extended. We make the
116
+ // minor assumption that no newly added callback is for a
117
+ // collectable object. That is, we only plug the hole where an
118
+ // object becomes collectable AFTER it is added but before the
119
+ // callback is run, not the hole where an object was ALREADY
120
+ // collectable but adds a background task for itself.
121
+ //
122
+ // It's necessary to traverse the whole list here, as the callbacks
123
+ // themselves can be in non-gc memory, and some of the cb->data
124
+ // objects themselves might be in non-gc memory.
111
125
background_callback_t * cb = (background_callback_t * )callback_head ;
112
- gc_collect_ptr (cb );
126
+ while (cb ) {
127
+ gc_collect_ptr (cb -> data );
128
+ cb = cb -> next ;
129
+ }
113
130
}
You can’t perform that action at this time.
0 commit comments