lestes::std::mem Namespace Reference


Classes

class  init_gc
 Initializer for gc. More...
class  gc
 Garbage collector. More...
class  a
class  aa
class  b
class  c
class  d
class  e
class  keystone
class  root_pointer
 Wrapped bare pointer. More...
class  simple_pointer
 Wrapped bare pointer. More...

Functions

void gc_test (void)

Variables

static init_gc initializer_gc


Function Documentation

void lestes::std::mem::gc_test ( void   ) 

Definition at line 214 of file gc.test.cc.

References lestes::std::mem::e::create(), lestes::std::mem::d::create(), lestes::std::mem::c::create(), lestes::std::mem::b::create(), lestes::std::mem::aa::create(), lestes::std::mem::a::create(), live, lestes::std::mem::gc::live_keystones(), lestes::std::mem::gc::live_roots(), and lestes::ui::run().

Referenced by main().

00215 {
00216         // sweep the objects created before the test
00217         gc::run();
00218         
00219         // memorize static roots and keystones
00220         ulint static_r = gc::live_roots();
00221         ulint static_k = gc::live_keystones();
00222 
00223         // jtbs
00224         live(0,0);
00225         gc::run();
00226         live(0,0);
00227         
00228         // single ptr
00229         {
00230                 ptr<a> a1;
00231                 live(1,0);
00232                 gc::run();
00233                 live(1,0);
00234         }
00235         live(0,0);
00236         
00237         // single object
00238         {
00239                 ptr<a> a2(a::create());
00240                 live(1,1);
00241                 gc::run();
00242                 live(1,1);
00243                 a2 = NULL;
00244                 live(1,1);
00245                 gc::run();
00246                 live(1,0);
00247         }
00248         live(0,0);
00249         
00250         // more objects for one ptr
00251         {
00252                 ptr<a> a3(a::create());
00253                 live(1,1);
00254                 a3 = a::create();
00255                 a3 = a::create();
00256                 a3 = a::create();
00257                 live(1,4);
00258                 gc::run();
00259                 live(1,1);
00260         }
00261         live(0,1);
00262         gc::run();
00263         live(0,0);
00264 
00265         // one object for more ptr
00266         {
00267                 ptr<a> a4(a::create());
00268                 live(1,1);
00269                 {
00270                         ptr<a> a5(a4);
00271                         live(2,1);
00272                         a4 = NULL;
00273                         gc::run();
00274                         live(2,1);
00275                 }
00276                 live(1,1);
00277                 gc::run();
00278                 live(1,0);
00279         }
00280         live(0,0);
00281 
00282         // descendant in ancestor ptr
00283         {
00284                 ptr<a> a6(aa::create());
00285                 live(1,1);
00286                 gc::run();
00287                 live(1,1);
00288                 ptr<a> a7(a6);
00289                 live(2,1);
00290                 a6 = NULL;
00291                 gc::run();
00292                 live(2,1);
00293                 a7 = NULL;
00294                 gc::run();
00295                 live(2,0);
00296         }
00297         live(0,0);
00298 
00299         // one level empty structure
00300         {
00301                 ptr<b> b1(b::create(NULL,NULL));
00302                 live(1,1);
00303                 gc::run();
00304                 live(1,1);
00305                 b1 = NULL;
00306                 gc::run();
00307                 live(1,0);
00308         }
00309         live(0,0);
00310 
00311         // one level structure
00312         {
00313                 ptr<b> b1(b::create(a::create(),aa::create()));
00314                 live(1,3);
00315                 gc::run();
00316                 live(1,3);
00317                 b1 = NULL;
00318                 gc::run();
00319                 live(1,0);
00320         }
00321         live(0,0);
00322 
00323         // one level shared structure
00324         {
00325                 ptr<a> a8(a::create());
00326                 ptr<b> b1(b::create(a8,aa::create()));
00327                 live(2,3);
00328                 gc::run();
00329                 live(2,3);
00330                 b1 = NULL;
00331                 gc::run();
00332                 live(2,1);
00333         }
00334         gc::run();
00335         live(0,0);
00336 
00337         // one level inherited structure
00338         {
00339                 ptr<c> c1(c::create(a::create(),aa::create(),a::create()));
00340                 live(1,4);
00341                 gc::run();
00342                 live(1,4);
00343                 c1 = NULL;
00344                 gc::run();
00345                 live(1,0);
00346         }
00347         live(0,0);
00348 
00349         // two level structure
00350         {
00351                 ptr<c> c2(c::create(a::create(),aa::create(),a::create()));
00352                 ptr<c> c3(c::create(a::create(),aa::create(),a::create()));
00353                 ptr<d> d1(d::create(c2,c3));
00354                 live(3,9);
00355                 gc::run();
00356                 live(3,9);
00357                 c2 = c3 = NULL;
00358                 gc::run();
00359                 live(3,9);
00360                 d1 = NULL;
00361                 gc::run();
00362                 live(3,0);
00363         }
00364         live(0,0);
00365 
00366         // cyclic structure
00367         {
00368                 ptr<e> e1(e::create(NULL));
00369                 ptr<e> e2(e::create(e::create(e::create(e::create(e1)))));
00370                 e1->link_set(e2);
00371                 live(2,5);
00372                 gc::run();
00373                 live(2,5);
00374                 e2 = NULL;
00375                 gc::run();
00376                 live(2,5);
00377                 e1 = NULL;
00378                 gc::run();
00379                 live(2,0);
00380         }
00381         live(0,0);
00382 }


Variable Documentation

init_gc lestes::std::mem::initializer_gc [static]

Static initializer object in each translation unit. Ensures the proper order of initialization.

Definition at line 71 of file gc.hh.


Generated on Mon Feb 12 18:26:01 2007 for lestes by doxygen 1.5.1-20070107