mirror of
https://review.haiku-os.org/haiku
synced 2025-02-14 01:29:14 +01:00
d73d70971b
- Introduce TeamMemoryBlockOwner to act as an interface for blocks to remove themselves from the manager when they expire. Consequently remove TeamMemoryBlock's direct reference to the block manager. - Simplify GetBlock() to remove unnecessary recursion. - Store dead blocks in a doubly linked list instead of another hash table. - Minor style fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42090 a95241bf-73f2-0310-859d-f6bbb57e9c96
68 lines
1.3 KiB
C++
68 lines
1.3 KiB
C++
/*
|
|
* Copyright 2011, Rene Gollent, rene@gollent.com.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef TEAM_MEMORY_BLOCK_MANAGER_H
|
|
#define TEAM_MEMORY_BLOCK_MANAGER_H
|
|
|
|
|
|
#include <Locker.h>
|
|
#include <Referenceable.h>
|
|
#include <util/DoublyLinkedList.h>
|
|
#include <util/OpenHashTable.h>
|
|
|
|
#include "Types.h"
|
|
|
|
|
|
struct MemoryBlockHashDefinition;
|
|
class TeamMemoryBlock;
|
|
|
|
|
|
class TeamMemoryBlockManager
|
|
{
|
|
public:
|
|
TeamMemoryBlockManager();
|
|
~TeamMemoryBlockManager();
|
|
|
|
status_t Init();
|
|
|
|
TeamMemoryBlock* GetMemoryBlock(target_addr_t address);
|
|
|
|
private:
|
|
struct Key;
|
|
struct MemoryBlockEntry;
|
|
struct MemoryBlockHashDefinition;
|
|
typedef BOpenHashTable<MemoryBlockHashDefinition> MemoryBlockTable;
|
|
typedef DoublyLinkedList<TeamMemoryBlock> DeadBlockTable;
|
|
|
|
private:
|
|
void _Cleanup();
|
|
void _MarkDeadBlock(target_addr_t address);
|
|
void _RemoveBlock(target_addr_t address);
|
|
|
|
private:
|
|
friend class TeamMemoryBlockOwner;
|
|
|
|
private:
|
|
BLocker fLock;
|
|
MemoryBlockTable* fActiveBlocks;
|
|
DeadBlockTable* fDeadBlocks;
|
|
};
|
|
|
|
|
|
class TeamMemoryBlockOwner
|
|
{
|
|
public:
|
|
TeamMemoryBlockOwner(
|
|
TeamMemoryBlockManager* manager);
|
|
~TeamMemoryBlockOwner();
|
|
|
|
void RemoveBlock(TeamMemoryBlock* block);
|
|
|
|
private:
|
|
TeamMemoryBlockManager* fBlockManager;
|
|
};
|
|
|
|
|
|
#endif // TEAM_MEMORY_BLOCK_MANAGER_H
|