亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cmemorypool.h

?? 內存池
?? H
字號:
/******************
CMemoryPool.h
******************/

/*!\file CMemoryPool.h
 * \brief Contains the "CMemoryPool" Class-defintion.
 */

#ifndef __INC_CMemoryPool_h__
#define __INC_CMemoryPool_h__

#include "IMemoryBlock.h"
#include "SMemoryChunk.h"

namespace MemPool
{

static const std::size_t DEFAULT_MEMORY_POOL_SIZE        = 1000 ;                          //!< Initial MemoryPool size (in Bytes)
static const std::size_t DEFAULT_MEMORY_CHUNK_SIZE       = 128 ;                           //!< Default MemoryChunkSize (in Bytes)
static const std::size_t DEFAULT_MEMORY_SIZE_TO_ALLOCATE = DEFAULT_MEMORY_CHUNK_SIZE * 2 ; //!< Default Minimal Memory-Size (in Bytes) to Allocate. 

/*!\class CMemoryPool
 * \brief MemoryPool-Class
 *
 * This class is the actual implementation of the IMemoryBlock - Interface.
 * It is responsible for all MemoryRequests (GetMemory() / FreeMemory()) and
 * manages the allocation/deallocation of Memory from the Operating-System.
 */
class CMemoryPool : public IMemoryBlock
{
  public :
    /*!
	Contructor
	\param [IN] sInitialMemoryPoolSize The Initial Size (in Bytes) of the Memory Pool
	\param [IN] sMemoryChunkSize The Size (in Bytes) each MemoryChunk can Manage. 
	            A low sMemoryChunkSize increases the MemoryPool runtime (bad), but decreases the Memory-overhead/fragmentation (good)
    \param [IN] sMinimalMemorySizeToAllocate The Minimal amount of Memory which is allocated (in Bytes).
	            That means, every time you have to allocate more Memory from the Operating-System,
				<b>at least</b> sMinimalMemorySizeToAllocate Bytes are allocated.
				When you have to request small amount of Memory very often, this will speed up
				the MemoryPool, beacause when you allocate a new Memory from the OS,
				you will allocate a small "Buffer" automatically, wich will prevent you from
				requesting OS-memory too often.
	\param [IN] bSetMemoryData Set to true, if you want to set all allocated/freed Memory to a specific
	            Value. Very usefull for debugging, but has a negativ impact on the runtime.
	*/
    CMemoryPool(const std::size_t &sInitialMemoryPoolSize = DEFAULT_MEMORY_POOL_SIZE, 
		        const std::size_t &sMemoryChunkSize = DEFAULT_MEMORY_CHUNK_SIZE,
				const std::size_t &sMinimalMemorySizeToAllocate = DEFAULT_MEMORY_SIZE_TO_ALLOCATE,
				bool bSetMemoryData = false) ;
    virtual ~CMemoryPool() ; //!< Destructor

	/*!
	  Get "sMemorySize" Bytes from the Memory Pool.
	  \param [IN] sMemorySize       Sizes (in Bytes) of Memory.
	  \return                       Pointer to a Memory-Block of "sMemorySize" Bytes, or NULL if an error occured. 
	*/
    virtual void *GetMemory(const std::size_t &sMemorySize) ;
    
	/*!
	  Free the allocated memory again....
	  \param [IN] ptrMemoryBlock    Pointer to a Block of Memory, which is to be freed (previoulsy allocated via "GetMemory()").
	  \param [IN] sMemorySize       Sizes (in Bytes) of Memory.
	*/
	virtual void FreeMemory(void *ptrMemoryBlock, const std::size_t &sMemoryBlockSize) ;

	/*!
	  Writes the contents of the MemoryPool to a File.
	  Note : This file can be quite large (several MB).
	  \param [IN] strFileName      FileName of the MemoryDump.
	  \return                      true on success, false otherwise 
	*/
    bool WriteMemoryDumpToFile(const std::string &strFileName) ;
	/*!
	  Check, if a Pointer is in the Memory-Pool.
	  Note : This Checks only if a pointer is inside the Memory-Pool,
	         and <b>not</b> if the Memory contains meaningfull data.
	  \param [IN] ptrPointer       Pointer to a Memory-Block which is to be checked.
	  \return                      true, if the Pointer could be found in the Memory-Pool, false otherwise.
	*/
	bool IsValidPointer(void *ptrPointer) ;
 
  private :
    /*!
	  Will Allocate <b>at least</b> "sMemorySize" Bytes of Memory from the Operating-System.
	  The Memory will be cut into Pieces and Managed by the MemoryChunk-Linked-List.
	  (See LinkChunksToData() for details).
	  \param [IN] sMemorySize      The Memory-Size (in Bytes) to allocate
	  \return                      true, if the Memory could be allocated, false otherwise (e.g. System is out of Memory, etc.)
	*/
    bool AllocateMemory(const std::size_t &sMemorySize) ;
	void FreeAllAllocatedMemory() ; //!< Will free all Aloocated Memory to the Operating-System again.

    unsigned int CalculateNeededChunks(const std::size_t &sMemorySize) ; //!< \return the Number of MemoryChunks needed to Manage "sMemorySize" Bytes.
    std::size_t CalculateBestMemoryBlockSize(const std::size_t &sRequestedMemoryBlockSize) ; //!< return the amount of Memory which is best Managed by the MemoryChunks.

    SMemoryChunk *FindChunkSuitableToHoldMemory(const std::size_t &sMemorySize) ; //!< \return a Chunk which can hold the requested amount of memory, or NULL, if none was found.
    SMemoryChunk *FindChunkHoldingPointerTo(void *ptrMemoryBlock) ; //!< Find a Chunk which "Data"-Member is Pointing to the given "ptrMemoryBlock", or NULL if none was found.

	SMemoryChunk *SkipChunks(SMemoryChunk *ptrStartChunk, unsigned int uiChunksToSkip) ; //!< Skip the given amount of Chunks, starting from the given ptrStartChunk. \return the Chunk at the "skipping"-Position.
    SMemoryChunk *SetChunkDefaults(SMemoryChunk *ptrChunk) ; //!< Set "Default"-Values to the given Chunk

    void FreeChunks(SMemoryChunk *ptrChunk) ; //!< Makes the memory linked to the given Chunk available in the MemoryPool again (by setting the "UsedSize"-Member to 0).
	void DeallocateAllChunks() ; //!< Deallocates all Memory needed by the Chunks back to the Operating-System.

    bool LinkChunksToData(SMemoryChunk *ptrNewChunk, unsigned int uiChunkCount, TByte *ptrNewMemBlock) ; //!< Link the given Memory-Block to the Linked-List of MemoryChunks...
	void SetMemoryChunkValues(SMemoryChunk *ptrChunk, const std::size_t &sMemBlockSize) ; //!< Set the "UsedSize"-Member of the given "ptrChunk" to "sMemBlockSize".
	bool RecalcChunkMemorySize(SMemoryChunk *ptrChunks, unsigned int uiChunkCount) ; //!< Recalcs the "DataSize"-Member of all Chunks whe the Memory-Pool grows (via "AllocateMemory()")

	std::size_t MaxValue(const std::size_t &sValueA, const std::size_t &sValueB) const ; //!< \return the greatest of the two input values (A or B)
	
    SMemoryChunk *m_ptrFirstChunk ;  //!< Pointer to the first Chunk in the Linked-List of Memory Chunks
    SMemoryChunk *m_ptrLastChunk ;   //!< Pointer to the last Chunk in the Linked-List of Memory Chunks
    SMemoryChunk *m_ptrCursorChunk ; //!< Cursor-Chunk. Used to speed up the navigation in the linked-List.

    std::size_t m_sTotalMemoryPoolSize ;  //!< Total Memory-Pool size in Bytes
    std::size_t m_sUsedMemoryPoolSize ;   //!< amount of used Memory in Bytes
    std::size_t m_sFreeMemoryPoolSize ;   //!< amount of free Memory in Bytes

    std::size_t m_sMemoryChunkSize ;     //!< amount of Memory which can be Managed by a single MemoryChunk.
    unsigned int m_uiMemoryChunkCount ;  //!< Total amount of "SMemoryChunk"-Objects in the Memory-Pool.
	unsigned int m_uiObjectCount ;       //!< Counter for "GetMemory()" / "FreeMemory()"-Operation. Counts (indirectly) the number of "Objects" inside the mem-Pool.

	bool m_bSetMemoryData ;                      //!< Set to "true", if you want to set all (de)allocated Memory to a predefined Value (via "memset()"). Usefull for debugging.
	std::size_t m_sMinimalMemorySizeToAllocate ; //!< The minimal amount of Memory which can be allocated via "AllocateMemory()".
} ;

}

#endif /* __INC_CMemoryPool_h__ */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷av一区二区三区gif| 日韩欧美你懂的| 中文字幕成人av| 日本精品裸体写真集在线观看 | 亚洲成av人片在线观看无码| 久久精品亚洲乱码伦伦中文| 精品国产露脸精彩对白| 久久免费精品国产久精品久久久久| 不卡的电影网站| 91亚洲永久精品| 99久久久国产精品| 91精品国产色综合久久不卡蜜臀| 在线看国产一区| 精品动漫一区二区三区在线观看| 日韩欧美高清在线| 亚洲日本在线天堂| 日韩在线一二三区| 国产成人av资源| 欧美欧美欧美欧美首页| 91精品婷婷国产综合久久性色| 欧美久久久久久久久中文字幕| 91精品国产美女浴室洗澡无遮挡| 日韩午夜在线观看视频| 国产精品麻豆欧美日韩ww| 欧美日韩一本到| 欧美日韩一区二区在线视频| 欧美剧情电影在线观看完整版免费励志电影 | 美日韩一区二区| 国产精品污网站| 久久久天堂av| 午夜精品久久久久久久久久久| 久久99国产精品尤物| 91在线观看下载| 精品美女一区二区| 亚洲国产色一区| 成人国产精品免费| 日韩欧美国产电影| 日韩精品免费视频人成| 久久精品国产精品青草| 国产成人亚洲综合a∨婷婷| 欧美高清视频不卡网| 中文字幕综合网| 美女一区二区三区在线观看| 在线不卡一区二区| 看电视剧不卡顿的网站| 三级亚洲高清视频| 美日韩一级片在线观看| 精品一区二区三区免费播放| 日本不卡中文字幕| 一区二区三区高清在线| 亚洲va在线va天堂| 91免费看片在线观看| 欧美一区二区视频网站| 亚洲一级在线观看| 99国产精品久久久久| 国产精品久久综合| 99re这里都是精品| 樱花草国产18久久久久| 欧美精品三级在线观看| 日本91福利区| 91精品国产综合久久精品| 香蕉乱码成人久久天堂爱免费| 精品视频免费在线| 亚洲综合激情网| 91精品国产欧美一区二区18 | 国产精品久久久久四虎| 懂色av中文字幕一区二区三区 | 一区二区三区四区视频精品免费 | 中文字幕av免费专区久久| 欧美欧美午夜aⅴ在线观看| 精品一区二区免费视频| 日韩美女视频一区| 国产人妖乱国产精品人妖| 国产成a人无v码亚洲福利| 国产精品国产精品国产专区不片| 99视频超级精品| 日韩精品一级中文字幕精品视频免费观看| 精品精品国产高清一毛片一天堂| 成人午夜在线视频| 一区二区三区国产豹纹内裤在线| 制服丝袜亚洲色图| 91亚洲午夜精品久久久久久| 久久91精品久久久久久秒播| 久久久精品黄色| 欧美日韩视频在线第一区| 93久久精品日日躁夜夜躁欧美| 婷婷久久综合九色综合绿巨人| 亚洲欧洲三级电影| 亚洲一区免费在线观看| 精品久久人人做人人爰| 激情综合色丁香一区二区| 亚洲观看高清完整版在线观看| 国产精品免费网站在线观看| 欧美一区二区在线不卡| 91小视频在线免费看| av欧美精品.com| 99精品久久只有精品| 99re成人精品视频| 99久久er热在这里只有精品15| 国产精品亚洲专一区二区三区| 午夜伊人狠狠久久| 亚洲综合久久久| 一区二区三区在线观看欧美| 欧美经典一区二区| 欧美大胆一级视频| 欧美一区二区三区在线看| 欧美日韩中文精品| 欧美区视频在线观看| 欧美成人在线直播| 中文字幕免费观看一区| 国产拍欧美日韩视频二区| 久久精品欧美一区二区三区不卡| 欧美日高清视频| 日韩视频一区二区三区在线播放| 欧美伊人久久久久久久久影院| 欧美美女一区二区在线观看| 成人自拍视频在线| 成人av午夜电影| 日本精品一区二区三区四区的功能| 91福利视频网站| 色综合久久中文字幕综合网| 欧美在线观看视频一区二区三区| 91在线码无精品| 欧美乱熟臀69xxxxxx| 欧美电影免费提供在线观看| 精品国产乱码久久久久久图片| 欧美一区二区日韩| 综合久久久久久久| 裸体健美xxxx欧美裸体表演| 99久久国产综合精品麻豆| 北条麻妃国产九九精品视频| 欧美日韩电影在线| 国产午夜久久久久| 亚洲视频一二区| 国产精品香蕉一区二区三区| 91热门视频在线观看| 欧美va亚洲va| 一区二区三区高清| 另类小说综合欧美亚洲| 欧美视频日韩视频在线观看| 精品国产网站在线观看| 亚洲综合丁香婷婷六月香| 高清国产一区二区| 精品少妇一区二区三区| 一区二区三区中文字幕在线观看| 麻豆精品视频在线观看视频| 成人深夜福利app| 成人精品免费看| 国产精品麻豆网站| 91豆麻精品91久久久久久| 国产精品国产精品国产专区不蜜 | 日韩av一二三| 久久久久久电影| 日本人妖一区二区| 久久麻豆一区二区| 蜜臀av性久久久久蜜臀aⅴ四虎| 欧美色手机在线观看| 亚洲国产人成综合网站| 亚洲国产激情av| 欧美视频一二三区| 免费av成人在线| 国产精品网曝门| 欧美日韩一区二区三区高清 | 精品国产免费人成电影在线观看四季| 久久国产欧美日韩精品| 色综合欧美在线视频区| 从欧美一区二区三区| 夜夜亚洲天天久久| 欧美日精品一区视频| 奇米综合一区二区三区精品视频| 亚洲欧洲99久久| 欧美精品在欧美一区二区少妇| 日韩毛片视频在线看| 91国偷自产一区二区开放时间| 日韩在线一二三区| 久久丝袜美腿综合| av一区二区不卡| 视频在线观看91| 日韩欧美黄色影院| 成人黄色网址在线观看| 一区二区视频在线| 欧美日韩午夜影院| 成人黄色片在线观看| 欧美96一区二区免费视频| 亚洲国产成人私人影院tom| 欧美亚洲愉拍一区二区| 91麻豆swag| 色综合天天综合网天天狠天天| 美国欧美日韩国产在线播放| 亚洲黄色录像片| 亚洲午夜久久久久久久久久久 | 亚洲欧美一区二区三区国产精品| 在线91免费看| 欧美亚洲综合久久| 欧美在线你懂的| 欧美日韩国产综合一区二区三区| 99久久久精品免费观看国产蜜| 成人在线视频首页| 懂色av中文字幕一区二区三区| 一本色道久久综合狠狠躁的推荐|