summaryrefslogtreecommitdiff
path: root/cpp/test/Freeze/evictor/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Freeze/evictor/Client.cpp')
-rw-r--r--cpp/test/Freeze/evictor/Client.cpp896
1 files changed, 448 insertions, 448 deletions
diff --git a/cpp/test/Freeze/evictor/Client.cpp b/cpp/test/Freeze/evictor/Client.cpp
index 41ee315faf2..cfafd704ef7 100644
--- a/cpp/test/Freeze/evictor/Client.cpp
+++ b/cpp/test/Freeze/evictor/Client.cpp
@@ -29,35 +29,35 @@ class ReadThread : public Thread
public:
ReadThread(vector<Test::ServantPrx>& servants) :
- _servants(servants)
+ _servants(servants)
{
}
virtual void
run()
{
- int loops = 10;
- while(loops-- > 0)
- {
- try
- {
- _servants[0]->getValue();
- test(false);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected
- }
- catch(...)
- {
- test(false);
- }
-
- for(int i = 1; i < static_cast<int>(_servants.size()); ++i)
- {
- test(_servants[i]->getValue() == i);
- }
- }
+ int loops = 10;
+ while(loops-- > 0)
+ {
+ try
+ {
+ _servants[0]->getValue();
+ test(false);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected
+ }
+ catch(...)
+ {
+ test(false);
+ }
+
+ for(int i = 1; i < static_cast<int>(_servants.size()); ++i)
+ {
+ test(_servants[i]->getValue() == i);
+ }
+ }
}
private:
@@ -71,72 +71,72 @@ public:
enum State { StateRunning, StateDeactivating, StateDeactivated };
ReadForeverThread(vector<Test::ServantPrx>& servants) :
- _servants(servants),
- _state(StateRunning)
+ _servants(servants),
+ _state(StateRunning)
{
}
virtual void
run()
{
- for(;;)
- {
- try
- {
- for(int i = 0; i < static_cast<int>(_servants.size()); ++i)
- {
- if(getState() == StateDeactivated)
- {
- _servants[i]->slowGetValue();
- test(false);
- }
- else
- {
- test(_servants[i]->slowGetValue() == i);
- }
- }
- }
- catch(const Ice::SocketException&)
- {
- //
- // Expected
- //
- test(validEx());
- return;
- }
- catch(const Ice::LocalException& e)
- {
- cerr << "Caught unexpected : " << e << endl;
- test(false);
- return;
- }
- catch(...)
- {
- test(false);
- return;
- }
- }
+ for(;;)
+ {
+ try
+ {
+ for(int i = 0; i < static_cast<int>(_servants.size()); ++i)
+ {
+ if(getState() == StateDeactivated)
+ {
+ _servants[i]->slowGetValue();
+ test(false);
+ }
+ else
+ {
+ test(_servants[i]->slowGetValue() == i);
+ }
+ }
+ }
+ catch(const Ice::SocketException&)
+ {
+ //
+ // Expected
+ //
+ test(validEx());
+ return;
+ }
+ catch(const Ice::LocalException& e)
+ {
+ cerr << "Caught unexpected : " << e << endl;
+ test(false);
+ return;
+ }
+ catch(...)
+ {
+ test(false);
+ return;
+ }
+ }
}
State
getState()
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- return _state;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ return _state;
}
bool
validEx()
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- return _state == StateDeactivating || _state == StateDeactivated;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ return _state == StateDeactivating || _state == StateDeactivated;
}
void
setState(State s)
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- _state = s;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ _state = s;
}
private:
@@ -152,99 +152,99 @@ public:
enum State { StateRunning, StateDeactivating, StateDeactivated };
AddForeverThread(const Test::RemoteEvictorPrx& evictor, int prefix) :
- _evictor(evictor),
- _state(StateRunning)
+ _evictor(evictor),
+ _state(StateRunning)
{
- ostringstream ostr;
- ostr << prefix;
- _prefix = ostr.str();
+ ostringstream ostr;
+ ostr << prefix;
+ _prefix = ostr.str();
}
virtual void
run()
{
- int index = 0;
-
- for(;;)
- {
- ostringstream ostr;
- ostr << _prefix << "-" << index;
- index++;
- string id = ostr.str();
- try
- {
- if(getState() == StateDeactivated)
- {
- _evictor->createServant(id, 0);
- test(false);
- }
- else
- {
- _evictor->createServant(id, 0);
- }
- }
- catch(const Test::EvictorDeactivatedException&)
- {
- test(validEx());
- //
- // Expected
- //
- return;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- test(validEx());
- //
- // Expected
- //
- return;
- }
- catch(const Ice::LocalException& e)
- {
- cerr << "Caught unexpected : " << e << endl;
- test(false);
- return;
- }
- catch(const IceUtil::Exception& e)
- {
- cerr << "Caught IceUtil::Exception : " << e << endl;
- cerr << "Index is " << index << endl;
- test(false);
- return;
- }
- catch(const std::exception& e)
- {
- cerr << "Caught std::exception : " << e.what() << endl;
- test(false);
- return;
- }
- catch(...)
- {
- cerr << "Caught unknown exception" << endl;
+ int index = 0;
+
+ for(;;)
+ {
+ ostringstream ostr;
+ ostr << _prefix << "-" << index;
+ index++;
+ string id = ostr.str();
+ try
+ {
+ if(getState() == StateDeactivated)
+ {
+ _evictor->createServant(id, 0);
+ test(false);
+ }
+ else
+ {
+ _evictor->createServant(id, 0);
+ }
+ }
+ catch(const Test::EvictorDeactivatedException&)
+ {
+ test(validEx());
+ //
+ // Expected
+ //
+ return;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ test(validEx());
+ //
+ // Expected
+ //
+ return;
+ }
+ catch(const Ice::LocalException& e)
+ {
+ cerr << "Caught unexpected : " << e << endl;
test(false);
- return;
- }
- }
+ return;
+ }
+ catch(const IceUtil::Exception& e)
+ {
+ cerr << "Caught IceUtil::Exception : " << e << endl;
+ cerr << "Index is " << index << endl;
+ test(false);
+ return;
+ }
+ catch(const std::exception& e)
+ {
+ cerr << "Caught std::exception : " << e.what() << endl;
+ test(false);
+ return;
+ }
+ catch(...)
+ {
+ cerr << "Caught unknown exception" << endl;
+ test(false);
+ return;
+ }
+ }
}
State
getState()
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- return _state;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ return _state;
}
bool
validEx()
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- return _state == StateDeactivating || _state == StateDeactivated;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ return _state == StateDeactivating || _state == StateDeactivated;
}
void
setState(State s)
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- _state = s;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ _state = s;
}
private:
@@ -259,96 +259,96 @@ class CreateDestroyThread : public Thread
public:
CreateDestroyThread(const Test::RemoteEvictorPrx& evictor, int id, int size) :
- _evictor(evictor),
- _size(size)
+ _evictor(evictor),
+ _size(size)
{
- ostringstream ostr;
- ostr << id;
- _id = ostr.str();
+ ostringstream ostr;
+ ostr << id;
+ _id = ostr.str();
}
virtual void
run()
{
- try
- {
- int loops = 50;
- while(loops-- > 0)
- {
- for(int i = 0; i < _size; i++)
- {
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
- if(id == _id)
- {
- //
- // Create when odd, destroy when even.
- //
-
- if(loops % 2 == 0)
- {
- Test::ServantPrx servant = _evictor->getServant(id);
- servant->destroy();
-
- //
- // Twice
- //
- try
- {
- servant->destroy();
- test(false);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected
- }
- }
- else
- {
- Test::ServantPrx servant = _evictor->createServant(id, i);
-
- //
- // Twice
- //
- try
- {
- servant = _evictor->createServant(id, 0);
- test(false);
- }
- catch(const Test::AlreadyRegisteredException&)
- {
- // Expected
- }
- }
- }
- else
- {
- //
- // Just read/write the value
- //
- Test::ServantPrx servant = _evictor->getServant(id);
- try
- {
- int val = servant->getValue();
- test(val == i || val == -i);
- servant->setValue(-val);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected from time to time
- }
- }
- }
- }
- }
- catch(...)
- {
- //
- // Unexpected!
- //
- test(false);
- }
+ try
+ {
+ int loops = 50;
+ while(loops-- > 0)
+ {
+ for(int i = 0; i < _size; i++)
+ {
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
+ if(id == _id)
+ {
+ //
+ // Create when odd, destroy when even.
+ //
+
+ if(loops % 2 == 0)
+ {
+ Test::ServantPrx servant = _evictor->getServant(id);
+ servant->destroy();
+
+ //
+ // Twice
+ //
+ try
+ {
+ servant->destroy();
+ test(false);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected
+ }
+ }
+ else
+ {
+ Test::ServantPrx servant = _evictor->createServant(id, i);
+
+ //
+ // Twice
+ //
+ try
+ {
+ servant = _evictor->createServant(id, 0);
+ test(false);
+ }
+ catch(const Test::AlreadyRegisteredException&)
+ {
+ // Expected
+ }
+ }
+ }
+ else
+ {
+ //
+ // Just read/write the value
+ //
+ Test::ServantPrx servant = _evictor->getServant(id);
+ try
+ {
+ int val = servant->getValue();
+ test(val == i || val == -i);
+ servant->setValue(-val);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected from time to time
+ }
+ }
+ }
+ }
+ }
+ catch(...)
+ {
+ //
+ // Unexpected!
+ //
+ test(false);
+ }
}
private:
Test::RemoteEvictorPrx _evictor;
@@ -379,32 +379,32 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
vector<Test::ServantPrx> servants;
for(i = 0; i < size; i++)
{
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
- servants.push_back(evictor->createServant(id, i));
- servants[i]->ice_ping();
-
- Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1");
- try
- {
- facet1->ice_ping();
- test(false);
- }
- catch(const Ice::FacetNotExistException&)
- {
- // Expected
- }
-
- servants[i]->addFacet("facet1", "data");
- facet1->ice_ping();
- facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
- test(facet1);
- facet1->setValue(10 * i);
- facet1->addFacet("facet2", "moreData");
- Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
- test(facet2);
- facet2->setValue(100 * i);
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
+ servants.push_back(evictor->createServant(id, i));
+ servants[i]->ice_ping();
+
+ Test::FacetPrx facet1 = Test::FacetPrx::uncheckedCast(servants[i], "facet1");
+ try
+ {
+ facet1->ice_ping();
+ test(false);
+ }
+ catch(const Ice::FacetNotExistException&)
+ {
+ // Expected
+ }
+
+ servants[i]->addFacet("facet1", "data");
+ facet1->ice_ping();
+ facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
+ test(facet1);
+ facet1->setValue(10 * i);
+ facet1->addFacet("facet2", "moreData");
+ Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
+ test(facet2);
+ facet2->setValue(100 * i);
}
//
@@ -414,14 +414,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
evictor->setSize(size);
for(i = 0; i < size; i++)
{
- test(servants[i]->getValue() == i);
- Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
- test(facet1);
- test(facet1->getValue() == 10 * i);
- test(facet1->getData() == "data");
- Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
- test(facet2);
- test(facet2->getData() == "moreData");
+ test(servants[i]->getValue() == i);
+ Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
+ test(facet1);
+ test(facet1->getValue() == 10 * i);
+ test(facet1->getData() == "data");
+ Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
+ test(facet2);
+ test(facet2->getData() == "moreData");
}
//
@@ -429,13 +429,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants[i]->setValue(i + 100);
- Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
- test(facet1);
- facet1->setValue(10 * i + 100);
- Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
- test(facet2);
- facet2->setValue(100 * i + 100);
+ servants[i]->setValue(i + 100);
+ Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
+ test(facet1);
+ facet1->setValue(10 * i + 100);
+ Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
+ test(facet2);
+ facet2->setValue(100 * i + 100);
}
//
@@ -445,13 +445,13 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
evictor->setSize(size);
for(i = 0; i < size; i++)
{
- test(servants[i]->getValue() == i + 100);
- Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
- test(facet1);
- test(facet1->getValue() == 10 * i + 100);
- Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
- test(facet2);
- test(facet2->getValue() == 100 * i + 100);
+ test(servants[i]->getValue() == i + 100);
+ Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
+ test(facet1);
+ test(facet1->getValue() == 10 * i + 100);
+ Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(facet1, "facet2");
+ test(facet2);
+ test(facet2->getValue() == 100 * i + 100);
}
//
// Test saving while busy
@@ -459,24 +459,24 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
Test::AMI_Servant_setValueAsyncPtr setCB = new AMI_Servant_setValueAsyncI;
for(i = 0; i < size; i++)
{
- //
- // Start a mutating operation so that the object is not idle.
- //
- servants[i]->setValueAsync_async(setCB, i + 300);
-
- test(servants[i]->getValue() == i + 100);
- //
- // This operation modifies the object state but is not saved
- // because the setValueAsync operation is still pending.
- //
- servants[i]->setValue(i + 200);
- test(servants[i]->getValue() == i + 200);
+ //
+ // Start a mutating operation so that the object is not idle.
+ //
+ servants[i]->setValueAsync_async(setCB, i + 300);
+
+ test(servants[i]->getValue() == i + 100);
+ //
+ // This operation modifies the object state but is not saved
+ // because the setValueAsync operation is still pending.
+ //
+ servants[i]->setValue(i + 200);
+ test(servants[i]->getValue() == i + 200);
- //
- // Force the response to setValueAsync
- //
- servants[i]->releaseAsync();
- test(servants[i]->getValue() == i + 300);
+ //
+ // Force the response to setValueAsync
+ //
+ servants[i]->releaseAsync();
+ test(servants[i]->getValue() == i + 300);
}
//
@@ -484,14 +484,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- try
- {
- servants[i]->addFacet("facet1", "foobar");
- test(false);
- }
- catch(const Test::AlreadyRegisteredException&)
- {
- }
+ try
+ {
+ servants[i]->addFacet("facet1", "foobar");
+ test(false);
+ }
+ catch(const Test::AlreadyRegisteredException&)
+ {
+ }
}
//
@@ -499,8 +499,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
try
{
- servants[0]->removeFacet("facet3");
- test(false);
+ servants[0]->removeFacet("facet3");
+ test(false);
}
catch(const Test::NotRegisteredException&)
{
@@ -512,8 +512,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants[i]->removeFacet("facet1");
- servants[i]->removeFacet("facet2");
+ servants[i]->removeFacet("facet1");
+ servants[i]->removeFacet("facet2");
}
//
@@ -521,10 +521,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
- test(facet1 == 0);
- Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2");
- test(facet2 == 0);
+ Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
+ test(facet1 == 0);
+ Test::FacetPrx facet2 = Test::FacetPrx::checkedCast(servants[i], "facet2");
+ test(facet2 == 0);
}
evictor->setSize(0);
@@ -532,10 +532,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
for(i = 0; i < size; i++)
{
- test(servants[i]->getValue() == i + 300);
+ test(servants[i]->getValue() == i + 300);
- Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
- test(facet1 == 0);
+ Test::FacetPrx facet1 = Test::FacetPrx::checkedCast(servants[i], "facet1");
+ test(facet1 == 0);
}
//
@@ -543,26 +543,26 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants[i]->destroy();
- try
- {
- servants[i]->getValue();
- test(false);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected
- }
-
- try
- {
- servants[i]->ice_ping();
- test(false);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected
- }
+ servants[i]->destroy();
+ try
+ {
+ servants[i]->getValue();
+ test(false);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected
+ }
+
+ try
+ {
+ servants[i]->ice_ping();
+ test(false);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected
+ }
}
//
@@ -571,11 +571,11 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
servants.clear();
for(i = 0; i < size; i++)
{
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
- servants.push_back(evictor->createServant(id, i));
- servants[i]->setTransientValue(i);
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
+ servants.push_back(evictor->createServant(id, i));
+ servants[i]->setTransientValue(i);
}
//
@@ -590,7 +590,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- test(servants[i]->getTransientValue() == -1);
+ test(servants[i]->getTransientValue() == -1);
}
//
@@ -598,9 +598,9 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants[i]->keepInCache();
- servants[i]->keepInCache();
- servants[i]->setTransientValue(i);
+ servants[i]->keepInCache();
+ servants[i]->keepInCache();
+ servants[i]->setTransientValue(i);
}
evictor->saveNow();
evictor->setSize(0);
@@ -612,7 +612,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- test(servants[i]->getTransientValue() == i);
+ test(servants[i]->getTransientValue() == i);
}
//
@@ -620,14 +620,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants[i]->release();
+ servants[i]->release();
}
evictor->saveNow();
evictor->setSize(0);
evictor->setSize(size);
for(i = 0; i < size; i++)
{
- test(servants[i]->getTransientValue() == i);
+ test(servants[i]->getTransientValue() == i);
}
//
@@ -635,14 +635,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- servants[i]->release();
+ servants[i]->release();
}
evictor->saveNow();
evictor->setSize(0);
evictor->setSize(size);
for(i = 0; i < size; i++)
{
- test(servants[i]->getTransientValue() == -1);
+ test(servants[i]->getTransientValue() == -1);
}
@@ -651,15 +651,15 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
//
for(i = 0; i < size; i++)
{
- try
- {
- servants[i]->release();
- test(false);
- }
- catch(const Test::NotRegisteredException&)
- {
- // Expected
- }
+ try
+ {
+ servants[i]->release();
+ test(false);
+ }
+ catch(const Test::NotRegisteredException&)
+ {
+ // Expected
+ }
}
@@ -673,12 +673,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
evictor->setSize(size);
for(i = 0; i < size; i++)
{
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
- servants[i] = evictor->getServant(id);
- test(servants[i]->getValue() == i);
+ servants[i] = evictor->getServant(id);
+ test(servants[i]->getValue() == i);
}
//
@@ -689,19 +689,19 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
servants[0]->destroy();
{
- const int threadCount = size * 2;
-
- ThreadPtr threads[threadCount];
- for(i = 0; i < threadCount; i++)
- {
- threads[i] = new ReadThread(servants);
- threads[i]->start();
- }
-
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->getThreadControl().join();
- }
+ const int threadCount = size * 2;
+
+ ThreadPtr threads[threadCount];
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i] = new ReadThread(servants);
+ threads[i]->start();
+ }
+
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->getThreadControl().join();
+ }
}
//
@@ -715,35 +715,35 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// CreateDestroy threads
//
{
- const int threadCount = size;;
-
- ThreadPtr threads[threadCount];
- for(i = 0; i < threadCount; i++)
- {
- threads[i] = new CreateDestroyThread(evictor, i, size);
- threads[i]->start();
- }
-
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->getThreadControl().join();
- }
-
- //
- // Verify all destroyed
- //
- for(i = 0; i < size; i++)
- {
- try
- {
- servants[i]->getValue();
- test(false);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected
- }
- }
+ const int threadCount = size;;
+
+ ThreadPtr threads[threadCount];
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i] = new CreateDestroyThread(evictor, i, size);
+ threads[i]->start();
+ }
+
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->getThreadControl().join();
+ }
+
+ //
+ // Verify all destroyed
+ //
+ for(i = 0; i < size; i++)
+ {
+ try
+ {
+ servants[i]->getValue();
+ test(false);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected
+ }
+ }
}
//
@@ -752,10 +752,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
servants.clear();
for(i = 0; i < size; i++)
{
- ostringstream ostr;
- ostr << i;
- string id = ostr.str();
- servants.push_back(evictor->createServant(id, i));
+ ostringstream ostr;
+ ostr << i;
+ string id = ostr.str();
+ servants.push_back(evictor->createServant(id, i));
}
//
@@ -763,30 +763,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// (really testing Ice here)
//
{
- const int threadCount = size;
-
- ReadForeverThreadPtr threads[threadCount];
- for(i = 0; i < threadCount; i++)
- {
- threads[i] = new ReadForeverThread(servants);
- threads[i]->start();
- }
+ const int threadCount = size;
+
+ ReadForeverThreadPtr threads[threadCount];
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i] = new ReadForeverThread(servants);
+ threads[i]->start();
+ }
- ThreadControl::sleep(Time::milliSeconds(500));
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->setState(ReadForeverThread::StateDeactivating);
- }
- evictor->deactivate();
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->setState(ReadForeverThread::StateDeactivated);
- }
+ ThreadControl::sleep(Time::milliSeconds(500));
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->setState(ReadForeverThread::StateDeactivating);
+ }
+ evictor->deactivate();
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->setState(ReadForeverThread::StateDeactivated);
+ }
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->getThreadControl().join();
- }
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->getThreadControl().join();
+ }
}
//
@@ -799,30 +799,30 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
// Deactivate in the middle of adds
//
{
- const int threadCount = size;
-
- AddForeverThreadPtr threads[threadCount];
- for(i = 0; i < threadCount; i++)
- {
- threads[i] = new AddForeverThread(evictor, i);
- threads[i]->start();
- }
-
- ThreadControl::sleep(Time::milliSeconds(500));
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->setState(AddForeverThread::StateDeactivating);
- }
- evictor->deactivate();
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->setState(AddForeverThread::StateDeactivated);
- }
-
- for(i = 0; i < threadCount; i++)
- {
- threads[i]->getThreadControl().join();
- }
+ const int threadCount = size;
+
+ AddForeverThreadPtr threads[threadCount];
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i] = new AddForeverThread(evictor, i);
+ threads[i]->start();
+ }
+
+ ThreadControl::sleep(Time::milliSeconds(500));
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->setState(AddForeverThread::StateDeactivating);
+ }
+ evictor->deactivate();
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->setState(AddForeverThread::StateDeactivated);
+ }
+
+ for(i = 0; i < threadCount; i++)
+ {
+ threads[i]->getThreadControl().join();
+ }
}