haiku/src/apps/debugger/TeamMemoryBlockManager.h
Rene Gollent d73d70971b * Various cleanups prompted by previous commit review:
- 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
2011-06-10 22:20:39 +00:00

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