瀏覽代碼

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 年之前
父節點
當前提交
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(); }) {
                 if constexpr (requires { that->revoke_weak_ptrs(); }) {
                     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;
             return new_ref_count;
         };
         };