summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/gc/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/gc/Client.cpp')
-rw-r--r--cpp/test/Ice/gc/Client.cpp634
1 files changed, 317 insertions, 317 deletions
diff --git a/cpp/test/Ice/gc/Client.cpp b/cpp/test/Ice/gc/Client.cpp
index 0e0f6fae130..86d599a91fb 100644
--- a/cpp/test/Ice/gc/Client.cpp
+++ b/cpp/test/Ice/gc/Client.cpp
@@ -45,12 +45,12 @@ struct N : public C
{
N()
{
- incNum();
+ incNum();
}
~N()
{
- decNum();
+ decNum();
}
};
@@ -60,12 +60,12 @@ struct N2 : public C2
{
N2()
{
- incNum();
+ incNum();
}
~N2()
{
- decNum();
+ decNum();
}
};
@@ -75,12 +75,12 @@ struct NN : public Node
{
NN()
{
- incNum();
+ incNum();
}
~NN()
{
- decNum();
+ decNum();
}
};
@@ -90,12 +90,12 @@ struct NL : public Leaf
{
NL()
{
- incNum();
+ incNum();
}
~NL()
{
- decNum();
+ decNum();
}
};
@@ -107,138 +107,138 @@ public:
GarbageProducer()
{
- _stop = false;
+ _stop = false;
}
virtual void run()
{
- ::IceUtil::ThreadControl t = getThreadControl();
-
- while(true)
- {
- {
- ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
- if(_stop)
- {
- return;
- }
- }
-
- t.yield();
-
- {
- NPtr n = new N;
- n->left = n;
- }
-
- {
- NPtr n = new N;
- n->left = n;
- n->right = n;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- n1->left = n2;
- n2->left = n1;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- n1->left = n2;
- n2->left = n1;
- n1->right = n2;
- n2->right = n1;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- n1->left = n2;
- n2->left = n1;
- n1->right = n1;
- n2->right = n2;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- n1->left = n2;
- n2->left = n3;
- n3->left = n1;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- n1->left = n2;
- n2->left = n3;
- n3->left = n1;
- n1->right = n2;
- n2->right = n3;
- n3->right = n1;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- n1->left = n2;
- n2->left = n3;
- n3->left = n1;
- n1->right = n3;
- n2->right = n1;
- n3->right = n2;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- NPtr n4 = new N;
- n1->left = n2;
- n2->left = n1;
- n2->right = n3;
- n3->left = n4;
- }
-
- {
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- NPtr n4 = new N;
- NPtr n5 = new N;
- NPtr n6 = new N;
- n1->left = n2;
- n2->left = n1;
- n2->right = n3;
- n3->left = n4;
- n4->right = n5;
- n5->right = n6;
- n6->right = n5;
- }
- }
+ ::IceUtil::ThreadControl t = getThreadControl();
+
+ while(true)
+ {
+ {
+ ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
+ if(_stop)
+ {
+ return;
+ }
+ }
+
+ t.yield();
+
+ {
+ NPtr n = new N;
+ n->left = n;
+ }
+
+ {
+ NPtr n = new N;
+ n->left = n;
+ n->right = n;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n1->right = n2;
+ n2->right = n1;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n1->right = n1;
+ n2->right = n2;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ n1->left = n2;
+ n2->left = n3;
+ n3->left = n1;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ n1->left = n2;
+ n2->left = n3;
+ n3->left = n1;
+ n1->right = n2;
+ n2->right = n3;
+ n3->right = n1;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ n1->left = n2;
+ n2->left = n3;
+ n3->left = n1;
+ n1->right = n3;
+ n2->right = n1;
+ n3->right = n2;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ NPtr n4 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n2->right = n3;
+ n3->left = n4;
+ }
+
+ {
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ NPtr n4 = new N;
+ NPtr n5 = new N;
+ NPtr n6 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n2->right = n3;
+ n3->left = n4;
+ n4->right = n5;
+ n5->right = n6;
+ n6->right = n5;
+ }
+ }
}
void stop()
{
- {
- ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
- _stop = true;
- notify();
- }
- getThreadControl().join();
+ {
+ ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
+ _stop = true;
+ notify();
+ }
+ getThreadControl().join();
}
void randomWait()
{
- ::IceUtil::Time waitTime = ::IceUtil::Time::milliSeconds(10 + rand() % 50);
- ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
- timedWait(waitTime);
+ ::IceUtil::Time waitTime = ::IceUtil::Time::milliSeconds(10 + rand() % 50);
+ ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this);
+ timedWait(waitTime);
}
private:
@@ -258,10 +258,10 @@ MyApplication::run(int argc, char* argv[])
{
cout << "testing single instance... " << flush;
{
- NPtr n = new N;
- test(getNum() == 1);
- Ice::collectGarbage();
- test(getNum() == 1);
+ NPtr n = new N;
+ test(getNum() == 1);
+ Ice::collectGarbage();
+ test(getNum() == 1);
}
test(getNum() == 0);
Ice::collectGarbage();
@@ -270,11 +270,11 @@ MyApplication::run(int argc, char* argv[])
cout << "testing single instance cycle... " << flush;
{
- NPtr n = new N;
- n->left = n;
- test(getNum() == 1);
- Ice::collectGarbage();
- test(getNum() == 1);
+ NPtr n = new N;
+ n->left = n;
+ test(getNum() == 1);
+ Ice::collectGarbage();
+ test(getNum() == 1);
}
test(getNum() == 1);
Ice::collectGarbage();
@@ -283,12 +283,12 @@ MyApplication::run(int argc, char* argv[])
cout << "testing single instance cycle with double pointers... " << flush;
{
- NPtr n = new N;
- n->left = n;
- n->right = n;
- test(getNum() == 1);
- Ice::collectGarbage();
- test(getNum() == 1);
+ NPtr n = new N;
+ n->left = n;
+ n->right = n;
+ test(getNum() == 1);
+ Ice::collectGarbage();
+ test(getNum() == 1);
}
test(getNum() == 1);
Ice::collectGarbage();
@@ -297,13 +297,13 @@ MyApplication::run(int argc, char* argv[])
cout << "testing double instance cycle... " << flush;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- n1->left = n2;
- n2->left = n1;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
test(getNum() == 2);
Ice::collectGarbage();
@@ -312,15 +312,15 @@ MyApplication::run(int argc, char* argv[])
cout << "testing double instance cycle with double pointers... " << flush;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- n1->left = n2;
- n2->left = n1;
- n1->right = n2;
- n2->right = n1;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n1->right = n2;
+ n2->right = n1;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
test(getNum() == 2);
Ice::collectGarbage();
@@ -329,15 +329,15 @@ MyApplication::run(int argc, char* argv[])
cout << "testing double instance cycle with looped pointers... " << flush;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- n1->left = n2;
- n2->left = n1;
- n1->right = n1;
- n2->right = n2;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n1->right = n1;
+ n2->right = n2;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
test(getNum() == 2);
Ice::collectGarbage();
@@ -346,15 +346,15 @@ MyApplication::run(int argc, char* argv[])
cout << "testing triple instance cycle... " << flush;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- n1->left = n2;
- n2->left = n3;
- n3->left = n1;
- test(getNum() == 3);
- Ice::collectGarbage();
- test(getNum() == 3);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ n1->left = n2;
+ n2->left = n3;
+ n3->left = n1;
+ test(getNum() == 3);
+ Ice::collectGarbage();
+ test(getNum() == 3);
}
test(getNum() == 3);
Ice::collectGarbage();
@@ -363,18 +363,18 @@ MyApplication::run(int argc, char* argv[])
cout << "testing triple instance cycle with double pointers... " << flush;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- n1->left = n2;
- n2->left = n3;
- n3->left = n1;
- n1->right = n2;
- n2->right = n3;
- n3->right = n1;
- test(getNum() == 3);
- Ice::collectGarbage();
- test(getNum() == 3);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ n1->left = n2;
+ n2->left = n3;
+ n3->left = n1;
+ n1->right = n2;
+ n2->right = n3;
+ n3->right = n1;
+ test(getNum() == 3);
+ Ice::collectGarbage();
+ test(getNum() == 3);
}
test(getNum() == 3);
Ice::collectGarbage();
@@ -383,18 +383,18 @@ MyApplication::run(int argc, char* argv[])
cout << "testing triple instance cycle with opposing pointers... " << flush;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- n1->left = n2;
- n2->left = n3;
- n3->left = n1;
- n1->right = n3;
- n2->right = n1;
- n3->right = n2;
- test(getNum() == 3);
- Ice::collectGarbage();
- test(getNum() == 3);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ n1->left = n2;
+ n2->left = n3;
+ n3->left = n1;
+ n1->right = n3;
+ n2->right = n1;
+ n3->right = n2;
+ test(getNum() == 3);
+ Ice::collectGarbage();
+ test(getNum() == 3);
}
test(getNum() == 3);
Ice::collectGarbage();
@@ -404,18 +404,18 @@ MyApplication::run(int argc, char* argv[])
cout << "testing cycle with trailing instances... " << flush;
NPtr n;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- NPtr n4 = new N;
- n1->left = n2;
- n2->left = n1;
- n2->right = n3;
- n3->left = n4;
- n = n3;
- test(getNum() == 4);
- Ice::collectGarbage();
- test(getNum() == 4);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ NPtr n4 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n2->right = n3;
+ n3->left = n4;
+ n = n3;
+ test(getNum() == 4);
+ Ice::collectGarbage();
+ test(getNum() == 4);
}
test(getNum() == 4);
Ice::collectGarbage();
@@ -428,23 +428,23 @@ MyApplication::run(int argc, char* argv[])
cout << "testing cycle with trailing instances and trailing cycle... " << flush;
{
- NPtr n1 = new N;
- NPtr n2 = new N;
- NPtr n3 = new N;
- NPtr n4 = new N;
- NPtr n5 = new N;
- NPtr n6 = new N;
- n1->left = n2;
- n2->left = n1;
- n2->right = n3;
- n3->left = n4;
- n4->right = n5;
- n5->right = n6;
- n6->right = n5;
- n = n4;
- test(getNum() == 6);
- Ice::collectGarbage();
- test(getNum() == 6);
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ NPtr n3 = new N;
+ NPtr n4 = new N;
+ NPtr n5 = new N;
+ NPtr n6 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ n2->right = n3;
+ n3->left = n4;
+ n4->right = n5;
+ n5->right = n6;
+ n6->right = n5;
+ n = n4;
+ test(getNum() == 6);
+ Ice::collectGarbage();
+ test(getNum() == 6);
}
test(getNum() == 6);
Ice::collectGarbage();
@@ -457,14 +457,14 @@ MyApplication::run(int argc, char* argv[])
cout << "testing sequence element cycle... " << flush;
{
- CSeq cs;
- cs.push_back(new N);
- cs.push_back(new N);
- cs[0]->left = cs[1];
- cs[1]->left = cs[0];
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ CSeq cs;
+ cs.push_back(new N);
+ cs.push_back(new N);
+ cs[0]->left = cs[1];
+ cs[1]->left = cs[0];
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
Ice::collectGarbage();
test(getNum() == 0);
@@ -472,16 +472,16 @@ MyApplication::run(int argc, char* argv[])
cout << "testing dictionary element cycle... " << flush;
{
- CDict cd;
- NPtr n1 = new N;
- NPtr n2 = new N;
- n1->left = n2;
- n2->left = n1;
- cd[0] = n1;
- cd[1] = n2;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ CDict cd;
+ NPtr n1 = new N;
+ NPtr n2 = new N;
+ n1->left = n2;
+ n2->left = n1;
+ cd[0] = n1;
+ cd[1] = n2;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
Ice::collectGarbage();
test(getNum() == 0);
@@ -489,18 +489,18 @@ MyApplication::run(int argc, char* argv[])
cout << "testing sequence of struct cycle... " << flush;
{
- SSeq ss;
- S s;
+ SSeq ss;
+ S s;
- ss.push_back(s);
- ss.push_back(s);
- ss[0].theC = new N;
- ss[1].theC = new N;
- ss[0].theC->left = ss[1].theC;
- ss[1].theC->left = ss[0].theC;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ ss.push_back(s);
+ ss.push_back(s);
+ ss[0].theC = new N;
+ ss[1].theC = new N;
+ ss[0].theC->left = ss[1].theC;
+ ss[1].theC->left = ss[0].theC;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
Ice::collectGarbage();
test(getNum() == 0);
@@ -508,18 +508,18 @@ MyApplication::run(int argc, char* argv[])
cout << "testing sequence of struct of dictionary cycle... " << flush;
{
- N2Ptr n2 = new N2;
- S2 s2;
+ N2Ptr n2 = new N2;
+ S2 s2;
- n2->theS2Seq.push_back(s2);
- n2->theS2Seq.push_back(s2);
- n2->theS2Seq[0].theC2Dict[0] = n2;
- n2->theS2Seq[0].theC2Dict[1] = n2;
- n2->theS2Seq[1].theC2Dict[0] = n2;
- n2->theS2Seq[1].theC2Dict[1] = n2;
- test(getNum() == 1);
- Ice::collectGarbage();
- test(getNum() == 1);
+ n2->theS2Seq.push_back(s2);
+ n2->theS2Seq.push_back(s2);
+ n2->theS2Seq[0].theC2Dict[0] = n2;
+ n2->theS2Seq[0].theC2Dict[1] = n2;
+ n2->theS2Seq[1].theC2Dict[0] = n2;
+ n2->theS2Seq[1].theC2Dict[1] = n2;
+ test(getNum() == 1);
+ Ice::collectGarbage();
+ test(getNum() == 1);
}
Ice::collectGarbage();
test(getNum() == 0);
@@ -529,61 +529,61 @@ MyApplication::run(int argc, char* argv[])
{
NNPtr nn = new NN;
- nn->l = new NL;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ nn->l = new NL;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
Ice::collectGarbage();
test(getNum() == 0);
{
NLPtr p;
- {
- NNPtr nn = new NN;
- p = new NL;
- nn->l = p;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
- }
- Ice::collectGarbage();
- test(getNum() == 1);
+ {
+ NNPtr nn = new NN;
+ p = new NL;
+ nn->l = p;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
+ }
+ Ice::collectGarbage();
+ test(getNum() == 1);
}
test(getNum() == 0);
{
- NNPtr nn = new NN;
- NLPtr nl = new NL;
- nn->l = nl;
- nn->n = nn;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ NNPtr nn = new NN;
+ NLPtr nl = new NL;
+ nn->l = nl;
+ nn->n = nn;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
test(getNum() == 2);
Ice::collectGarbage();
test(getNum() == 0);
{
- NNPtr nn1 = new NN;
- NNPtr nn2 = new NN;
- NLPtr nl = new NL;
- nn1->l = nl;
- nn1->n = nn2;
- nn2->l = nl;
- nn2->n = nn1;
- test(getNum() == 3);
- Ice::collectGarbage();
- test(getNum() == 3);
+ NNPtr nn1 = new NN;
+ NNPtr nn2 = new NN;
+ NLPtr nl = new NL;
+ nn1->l = nl;
+ nn1->n = nn2;
+ nn2->l = nl;
+ nn2->n = nn1;
+ test(getNum() == 3);
+ Ice::collectGarbage();
+ test(getNum() == 3);
}
test(getNum() == 3);
Ice::collectGarbage();
test(getNum() == 0);
{
- NLPtr nl = new NL;
- test(getNum() == 1);
+ NLPtr nl = new NL;
+ test(getNum() == 1);
}
test(getNum() == 0);
Ice::collectGarbage();
@@ -591,10 +591,10 @@ MyApplication::run(int argc, char* argv[])
{
NNPtr nn1 = new NN;
- nn1->n = new NN;
- test(getNum() == 2);
- Ice::collectGarbage();
- test(getNum() == 2);
+ nn1->n = new NN;
+ test(getNum() == 2);
+ Ice::collectGarbage();
+ test(getNum() == 2);
}
test(getNum() == 0);
Ice::collectGarbage();
@@ -619,12 +619,12 @@ MyApplication::run(int argc, char* argv[])
for(int i = 0; i < 50; ++i)
{
- if(interrupted())
- {
- break;
- }
- garbageThread->randomWait();
- Ice::collectGarbage();
+ if(interrupted())
+ {
+ break;
+ }
+ garbageThread->randomWait();
+ Ice::collectGarbage();
}
garbageThread->stop();
@@ -632,13 +632,13 @@ MyApplication::run(int argc, char* argv[])
Ice::collectGarbage();
if(!interrupted())
{
- test(getNum() == 0);
- cout << "ok" << endl;
- return EXIT_SUCCESS;
+ test(getNum() == 0);
+ cout << "ok" << endl;
+ return EXIT_SUCCESS;
}
else
{
- return 130; // SIGINT + 128
+ return 130; // SIGINT + 128
}
}