Social Reiot

Social Game Developer wandering in strange dungeon.

Boost::singleton_pool 사용법

1
2
3
4
5
6
7
8
9
10
11
12
struct CharArray512 {};

int _tmain(int argc, _TCHAR* argv[])
{
  typedef boost::singleton_pool<CharArray512,512> TestPool;

  void * pBuf = TestPool::malloc();
  assert( pBuf > 0 );
  TestPool::free(pBuf);

  return 0;
}

singleton_pool 의 첫번째 템플릿 파라미터인 태그는, 동일한 크기의 버퍼에 대해서 각각 풀을 사용해야 할 때 구분자로 사용된다.

Comments