クラス テンプレート langedge::NewByBlockAllocator< BS >

ブロックアロケータを使用した placement new を持つ抽象クラス. [詳細]

#include <memutil.hpp>

すべてのメンバ一覧

Public 型

typedef BlockAllocator< BS > Allocator
 使用するブロックアロケータに、Allocator という名前をつける

Public メソッド

void * operator new (size_t size, BlockAllocator< BS > *allocator)
 ブロックアロケータ Allocator 型のオブジェクトからメモリを確保する placement new.
void * operator new (size_t size, BlockAllocator< BS > &allocator)
void operator delete (void *, BlockAllocator< BS > *)
 オブジェクトの解放 (何もしない)
void operator delete (void *, BlockAllocator< BS > &)
void operator delete (void *)
 オブジェクトの解放.


説明

template<size_t BS = 0x10000>
class langedge::NewByBlockAllocator< BS >

ブロックアロケータを使用した placement new を持つ抽象クラス.

このクラスから派生させて使う。 使用するブロックアロケータの型は、Allocator という名前で typedef される。 Allocator 型のオブジェクトを生成し、 それを引数として new を呼ぶ。
new した派生クラスのオブジェクトを delete しても メモリ領域自体は解放されないので、適当なタイミングで ブロックアロケータの release を呼んでやる。ただし、 release を呼ぶと、それまでに new したオブジェクトは すべて無効になるので注意すること。逆に言うと、派生オブジェクトに 内包される部品オブジェクトの解体をする必要がなければ、あえて delete を 呼ぶ必要もないということ。

典型的な使い方は次の通り:

 class Hoge : public NewByBlockAllocator<> { };

 Hoge::Allocator hogeAllocator;

 Hoge *hoge = new(hogeAllocator) Hoge;
 // do something...
 deltele hoge;  // if necessary
 // repeat above...
 hogeAllocator.release();
 

引数:
BS 一度に確保するブロックの大きさ (デフォルト: 64KB)


型定義

template<size_t BS = 0x10000>
typedef BlockAllocator<BS> langedge::NewByBlockAllocator< BS >::Allocator
 

使用するブロックアロケータに、Allocator という名前をつける


関数

template<size_t BS = 0x10000>
void* langedge::NewByBlockAllocator< BS >::operator new size_t  size,
BlockAllocator< BS > *  allocator
[inline]
 

ブロックアロケータ Allocator 型のオブジェクトからメモリを確保する placement new.

引数:
size Node オブジェクトのサイズ
allocator ブロックアロケータ Allocator型のオブジェクト
戻り値:
確保したメモリブロックへのポインタ

template<size_t BS = 0x10000>
void* langedge::NewByBlockAllocator< BS >::operator new size_t  size,
BlockAllocator< BS > &  allocator
[inline]
 

template<size_t BS = 0x10000>
void langedge::NewByBlockAllocator< BS >::operator delete void *  ,
BlockAllocator< BS > * 
[inline]
 

オブジェクトの解放 (何もしない)

template<size_t BS = 0x10000>
void langedge::NewByBlockAllocator< BS >::operator delete void *  ,
BlockAllocator< BS > & 
[inline]
 

template<size_t BS = 0x10000>
void langedge::NewByBlockAllocator< BS >::operator delete void *   )  [inline]
 

オブジェクトの解放.

非配置版。これを定義しておかないと、VC++ で、p->~Foo(); のように明示的に デストラクタを呼んだとき、「operator delete が無い」といってエラーになる。 理由は不明。


このクラスの説明は次のファイルから生成されました:
LangEdge ライブラリに対してFri May 6 22:43:03 2005に生成されました。  doxygen 1.4.2