固定長バッファーからのスケーラブルなメモリー割り当て用のテンプレート・クラス。
class fixed_pool;
#define TBB_PREVIEW_MEMORY_POOL 1 #include "tbb/memory_pool.h"
fixed_pool は、プロセッサーの数でスケールするようにメモリーの割り当てと解放を行います。最初に、割り当て可能なすべてのメモリーがコンストラクターの引数で渡されます。fixed_pool はメモリープール・コンセプトをモデル化します。
#define TBB_PREVIEW_MEMORY_POOL 1 #include "tbb/memory_pool.h" ... char buf[1024*1024]; tbb::fixed_pool my_pool(buf, 1024*1024); void* my_ptr = my_pool.malloc(10); my_pool.free(my_ptr);}
上記のコードは、固定プールからの単純な割り当て例です。
namespace tbb { class fixed_pool : no_copy { public: fixed_pool(void *buffer, size_t size) throw(std::bad_alloc); ~fixed_pool(); void recycle(); void *malloc(size_t size); void free(void* ptr); void *realloc(void* ptr, size_t size); }; }
メンバー | 説明 |
---|---|
fixed_pool(void *buffer, size_t size) | バッファーが指しているメモリーとそのサイズを管理するためのメモリープールを構築します。 ランタイムにクラスのインスタンスの構築に失敗した場合、bad_alloc 例外をスローします。 |