|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _TBIGMEMORYMANAGER_
|
|
Toshihiro Shimizu |
890ddd |
#define _TBIGMEMORYMANAGER_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class Chunkinfo;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TSYSTEM_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tthreadmessage.h"
|
|
Toshihiro Shimizu |
890ddd |
class TRaster;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TBigMemoryManager
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TThread::Mutex m_mutex;
|
|
Toshihiro Shimizu |
890ddd |
UCHAR *m_theMemory;
|
|
Toshihiro Shimizu |
890ddd |
map<uchar *,="" chunkinfo=""> m_chunks;</uchar>
|
|
Toshihiro Shimizu |
890ddd |
UCHAR *allocate(UINT &size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TUINT32 m_availableMemory, m_allocatedMemory;
|
|
Toshihiro Shimizu |
890ddd |
map<uchar *,="" chunkinfo="">::iterator shiftBlock(const map<uchar *,="" chunkinfo="">::iterator &it, TUINT32 offset);</uchar></uchar>
|
|
Toshihiro Shimizu |
890ddd |
TRaster *findRaster(TRaster *ras);
|
|
Toshihiro Shimizu |
890ddd |
void checkConsistency();
|
|
Toshihiro Shimizu |
890ddd |
UCHAR *remap(TUINT32 RequestedSize);
|
|
Toshihiro Shimizu |
890ddd |
void printLog(TUINT32 size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TBigMemoryManager();
|
|
Toshihiro Shimizu |
890ddd |
~TBigMemoryManager();
|
|
Toshihiro Shimizu |
890ddd |
bool init(TUINT32 sizeinKb);
|
|
Toshihiro Shimizu |
890ddd |
bool putRaster(TRaster *ras, bool canPutOnDisk = true);
|
|
Toshihiro Shimizu |
890ddd |
bool releaseRaster(TRaster *ras);
|
|
Toshihiro Shimizu |
890ddd |
void lock(UCHAR *buffer);
|
|
Toshihiro Shimizu |
890ddd |
void unlock(UCHAR *buffer);
|
|
Toshihiro Shimizu |
890ddd |
UCHAR *getBuffer(UINT size);
|
|
Toshihiro Shimizu |
890ddd |
static TBigMemoryManager *instance();
|
|
Toshihiro Shimizu |
890ddd |
bool isActive() const { return m_theMemory != 0; }
|
|
Toshihiro Shimizu |
890ddd |
//void releaseSubraster(UCHAR *chunk, TRaster*subRas);
|
|
Toshihiro Shimizu |
890ddd |
TUINT32 getAvailableMemoryinKb() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(m_theMemory != 0);
|
|
Toshihiro Shimizu |
890ddd |
return m_availableMemory >> 10;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void getRasterInfo(int &rasterCount, TUINT32 &totRasterMemInKb, int ¬CachedRasterCount, TUINT32 ¬CachedRasterMemInKb);
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
TUINT32 m_totRasterMemInKb;
|
|
Toshihiro Shimizu |
890ddd |
void printMap();
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
int getAllocationPeak();
|
|
Toshihiro Shimizu |
890ddd |
int getAllocationMean();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setRunOutOfContiguousMemoryHandler(void (*callback)(unsigned long size));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
friend class TRaster;
|
|
Toshihiro Shimizu |
890ddd |
void (*m_runOutCallback)(unsigned long);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|