Example #1
0
void test1()
{
    ObjectPool<SmallObject> op;
    SmallObject* s = op.get();
    op.put(s);
    s = op.get();
    s = op.get();
    s = op.get();
    s = op.get();

    printf("++++++++++++++++\n");
}
Example #2
0
void test2()
{
    TimeFilm tm("object pool: ");
    ObjectPool<SmallObject> op;
    SmallObject* s = 0;

    //int m = 1000000;
    int m = 100;
    Random rnd;
    const char* hello = "hello";
    while (--m)
    {
        //s = op.get();
        s = op.get(m,hello);
#if 1
        if (s && rnd(2))
        {
            printf("put\n");
            op.put(s);
        }
#endif
    }
}