Skip to content

Instantly share code, notes, and snippets.

@luyao795
Created August 24, 2017 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luyao795/40a98a7e3e4b6c6736c89a37a17d1687 to your computer and use it in GitHub Desktop.
Save luyao795/40a98a7e3e4b6c6736c89a37a17d1687 to your computer and use it in GitHub Desktop.
Header file for Fixed Size Allocator Manager
#ifndef FSAMANAGER_H
#define FSAMANAGER_H
#include <vector>
#include "FixedSizeAllocator.h"
#define NUM_FSA 4
namespace Engine
{
class FSAManager
{
public:
FSAManager();
static FSAManager* create();
static FSAManager* getInstance();
void destroy();
void createFSA();
bool isListEmpty(FixedSizeAllocator* list[], const size_t length);
void clearList(FixedSizeAllocator* list[], const size_t length);
FixedSizeAllocator* findFixedSizeAllocator(size_t size);
FixedSizeAllocator** getList();
private:
~FSAManager();
static BlockAllocator* inst;
static const size_t numFSA = 4;
// Size: 8, 16, 32, 64
const size_t multiplier[4] = {1, 2, 4, 8};
const size_t smallestSize = 8;
const size_t numBlock = 100;
static FSAManager* instance;
//static FixedSizeAllocator** list;
static FixedSizeAllocator* fixedList[NUM_FSA];
};
}
#endif // !FSAMANAGER_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment