mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
Kernel: Port VMObject to ListedRefCounted
The VMObject class now manages its own instance list (it was previously a member of MemoryManager.) Removal from the list is done safely on the last unref(), closing a race window in the previous implementation. Note that VMObject::all_instances() now has its own lock instead of using the global MM lock.
This commit is contained in:
parent
3a2d888913
commit
7979b5a8bb
4 changed files with 26 additions and 28 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Library/ListedRefCounted.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
|
||||
|
@ -25,7 +26,8 @@ public:
|
|||
virtual void vmobject_deleted(VMObject&) = 0;
|
||||
};
|
||||
|
||||
class VMObject : public RefCounted<VMObject>
|
||||
class VMObject
|
||||
: public ListedRefCounted<VMObject>
|
||||
, public Weakable<VMObject> {
|
||||
friend class MemoryManager;
|
||||
friend class Region;
|
||||
|
@ -95,7 +97,8 @@ private:
|
|||
Region::ListInVMObject m_regions;
|
||||
|
||||
public:
|
||||
using List = IntrusiveList<VMObject, RawPtr<VMObject>, &VMObject::m_list_node>;
|
||||
using AllInstancesList = IntrusiveList<VMObject, RawPtr<VMObject>, &VMObject::m_list_node>;
|
||||
static SpinLockProtectedValue<VMObject::AllInstancesList>& all_instances();
|
||||
};
|
||||
|
||||
template<typename Callback>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue