コード例 #1
0
ファイル: main.cpp プロジェクト: CCJY/coliru
 int main(int argc, char *argv[])
 {
      ObjectPool<A> op;
	  
	  A* first = op.hold();
	  A* second = op.hold();
	  A* third = op.hold();
	  first->i = 1;
	  second->i =2 ;
	  third->i =3;
	  
	  op.release(second); 
	  op.release(first); 
      op.release(third); 
	  A* isitsecond = op.hold();
      std::cout << isitsecond->i  << std::endl;
      A* isitfirst = op.hold();
      std::cout << isitfirst->i  << std::endl;
	  
	   A* isitthird = op.hold();
      std::cout << isitthird->i  << std::endl;
      
	  A* notinpool ;
      op.release(notinpool);
	  //delete notinpool;
 }
コード例 #2
0
ファイル: main.cpp プロジェクト: shindavid/hunl
int main() {
  ObjectPool<int32_t, 128, false> pool;

  int32_t* a = pool.fetch();
  int32_t* b = pool.fetch();
  int32_t* c = pool.fetch();
  int32_t* d = pool.fetch();

  pool.release(b);
  int32_t* e = pool.fetch();

  fprintf(stdout, "fetch() %p\n", a);
  fprintf(stdout, "fetch() %p\n", b);
  fprintf(stdout, "fetch() %p\n", c);
  fprintf(stdout, "fetch() %p\n", d);
  fprintf(stdout, "fetch() %p\n", e);
  return 0;
}