Просмотр исходного кода

Kernel: Make ListedRefCounted::unref() call optional list removal helper

Look for remove_from_secondary_lists() and call it on the ref-counting
target if present *while the lock is held*.

This allows listed-ref-counted objects to be present in multiple lists
and still have synchronized removal on final unref.
Andreas Kling 3 лет назад
Родитель
Сommit
3550f12543
1 измененных файлов с 2 добавлено и 0 удалено
  1. 2 0
      Kernel/Library/ListedRefCounted.h

+ 2 - 0
Kernel/Library/ListedRefCounted.h

@@ -34,6 +34,8 @@ public:
                 if constexpr (requires { that->revoke_weak_ptrs(); }) {
                     that->revoke_weak_ptrs();
                 }
+                if constexpr (requires { that->remove_from_secondary_lists(); })
+                    that->remove_from_secondary_lists();
             }
             return new_ref_count;
         };