summaryrefslogtreecommitdiff
path: root/cpp/test/Freeze/dbmap/Client.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2002-09-27 22:47:41 +0000
committerBenoit Foucher <benoit@zeroc.com>2002-09-27 22:47:41 +0000
commit7ce10c119e868dfd13783a51ca34a6200f453926 (patch)
tree9eded69968afc96da3d271edf5b1f670dde6718a /cpp/test/Freeze/dbmap/Client.cpp
parentAdded --depend to slice2freezej (diff)
downloadice-7ce10c119e868dfd13783a51ca34a6200f453926.tar.bz2
ice-7ce10c119e868dfd13783a51ca34a6200f453926.tar.xz
ice-7ce10c119e868dfd13783a51ca34a6200f453926.zip
Added small stress test
Diffstat (limited to 'cpp/test/Freeze/dbmap/Client.cpp')
-rw-r--r--cpp/test/Freeze/dbmap/Client.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp
index c20729156c1..be9ab8b6bc8 100644
--- a/cpp/test/Freeze/dbmap/Client.cpp
+++ b/cpp/test/Freeze/dbmap/Client.cpp
@@ -8,6 +8,7 @@
//
// **********************************************************************
+#include <IceUtil/IceUtil.h>
#include <Freeze/Freeze.h>
#include <TestCommon.h>
#include <ByteIntMapXML.h>
@@ -52,6 +53,33 @@ populateDB(MAP& m)
}
template<class MAP>
+class StressThread : public IceUtil::Thread
+{
+public:
+
+ StressThread(MAP& m) :
+ _map(m)
+ {
+ }
+
+ virtual void
+ run()
+ {
+ for(int i = 0; i < 50; ++i)
+ {
+ typename MAP::iterator p = _map.begin();
+ assert(p != _map.end());
+ Byte b = p->second;
+ test(b >= 0);
+ }
+ }
+
+private:
+
+ MAP& _map;
+};
+
+template<class MAP>
static int
run(int argc, char* argv[], MAP& m)
{
@@ -290,6 +318,19 @@ run(int argc, char* argv[], MAP& m)
}
cout << "ok" << endl;
+ cout << " testing concurrent access... " << flush;
+ vector<IceUtil::ThreadControl> controls;
+ for(int i = 0; i < 10; ++i)
+ {
+ IceUtil::ThreadPtr t = new StressThread<MAP>(m);
+ controls.push_back(t->start());
+ }
+ for(vector<IceUtil::ThreadControl>::iterator p = controls.begin(); p != controls.end(); ++p)
+ {
+ p->join();
+ }
+ cout << "ok" << endl;
+
return EXIT_SUCCESS;
}