[mapguide-commits] r4718 - sandbox/adsk/2.1/Server/src/UnitTesting

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Mar 30 14:01:57 EDT 2010


Author: brucedechant
Date: 2010-03-30 14:01:57 -0400 (Tue, 30 Mar 2010)
New Revision: 4718

Modified:
   sandbox/adsk/2.1/Server/src/UnitTesting/TestTileService.cpp
Log:
Cleanup TileServer unit tests

Notes:
- Created a special thread group for the tile service unit tests so that they don't interfere with any other threads


Modified: sandbox/adsk/2.1/Server/src/UnitTesting/TestTileService.cpp
===================================================================
--- sandbox/adsk/2.1/Server/src/UnitTesting/TestTileService.cpp	2010-03-30 18:00:35 UTC (rev 4717)
+++ sandbox/adsk/2.1/Server/src/UnitTesting/TestTileService.cpp	2010-03-30 18:01:57 UTC (rev 4718)
@@ -27,11 +27,10 @@
 // determines the number of requests to make, as a factor of the number of tiles
 #define REQUEST_FACTOR 20
 
-#ifdef _WIN32
+// define thread group for tiling tests 
+#define THREAD_GROUP 65535
+
 static const INT32 MG_TEST_THREADS = 4;
-#else
-static const INT32 MG_TEST_THREADS = 2;
-#endif
 
 const STRING TEST_LOCALE = L"en";
 
@@ -407,8 +406,8 @@
                         threadData[i].tileRow  = tileRows[nTile];
                         threadData[i].tileCol  = tileCols[nTile];
 
-                        // spawn a new thread
-                        int thid = manager->spawn(ACE_THR_FUNC(GetTileWorker), &threadData[i]);
+                        // spawn a new thread using a specific group id
+                        int thid = manager->spawn(ACE_THR_FUNC(GetTileWorker), &threadData[i], 0, NULL, NULL, 0, THREAD_GROUP);
                         nRequest++;
                     }
 
@@ -424,7 +423,7 @@
 
             // under Linux we get a deadlock if we don't call this every once in a while
             if (nRequest % 25 == 0)
-                manager->wait();
+                manager->wait_grp(THREAD_GROUP);
             else
             {
                 // pause briefly (10ms) before checking again
@@ -433,8 +432,8 @@
             }
         }
 
-        // make sure the manager is in a good state
-        manager->wait();
+        // make sure all threads in the group have completed
+        manager->wait_grp(THREAD_GROUP);
 
         // done with the tile indices
         delete [] tileRows;
@@ -602,8 +601,8 @@
                         threadData[i].tileRow = tileRows[nRequest];
                         threadData[i].tileCol = tileCols[nRequest];
 
-                        // spawn a new thread
-                        int thid = manager->spawn(ACE_THR_FUNC(SetTileWorker), &threadData[i]);
+                        // spawn a new thread using a specific group id
+                        int thid = manager->spawn(ACE_THR_FUNC(SetTileWorker), &threadData[i], 0, NULL, NULL, 0, THREAD_GROUP);
                         nRequest++;
                     }
 
@@ -619,7 +618,7 @@
 
             // under Linux we get a deadlock if we don't call this every once in a while
             if (nRequest % 25 == 0)
-                manager->wait();
+                manager->wait_grp(THREAD_GROUP);
             else
             {
                 // pause briefly (10ms) before checking again
@@ -628,8 +627,8 @@
             }
         }
 
-        // make sure the manager is in a good state
-        manager->wait();
+        // make sure all threads in the group have completed
+        manager->wait_grp(THREAD_GROUP);
 
         // At this point all the tiles in the cache should be set.
         // Let's now randomly replace these tiles.
@@ -665,8 +664,8 @@
                         threadData[i].tileRow = tileRows[nTile];
                         threadData[i].tileCol = tileCols[nTile];
 
-                        // spawn a new thread
-                        int thid = manager->spawn(ACE_THR_FUNC(SetTileWorker), &threadData[i]);
+                        // spawn a new thread using a specific group id
+                        int thid = manager->spawn(ACE_THR_FUNC(SetTileWorker), &threadData[i], 0, NULL, NULL, 0, THREAD_GROUP);
                         nRequest++;
                     }
 
@@ -682,7 +681,7 @@
 
             // under Linux we get a deadlock if we don't call this every once in a while
             if (nRequest % 25 == 0)
-                manager->wait();
+                manager->wait_grp(THREAD_GROUP);
             else
             {
                 // pause briefly (10ms) before checking again
@@ -691,8 +690,8 @@
             }
         }
 
-        // make sure the manager is in a good state
-        manager->wait();
+        // make sure all threads in the group have completed
+        manager->wait_grp(THREAD_GROUP);
 
         // done with the tile indices
         delete [] tileRows;
@@ -799,9 +798,9 @@
                         // spawn a new thread - 75% of the calls are gets, 25% are sets
                         int thid;
                         if ((double)rand() < 0.75 * (double)RAND_MAX)
-                            thid = manager->spawn(ACE_THR_FUNC(GetTileWorker), &threadData[i]);
+                            thid = manager->spawn(ACE_THR_FUNC(GetTileWorker), &threadData[i], 0, NULL, NULL, 0, THREAD_GROUP);
                         else
-                            thid = manager->spawn(ACE_THR_FUNC(SetTileWorker), &threadData[i]);
+                            thid = manager->spawn(ACE_THR_FUNC(SetTileWorker), &threadData[i], 0, NULL, NULL, 0, THREAD_GROUP);
                         nRequest++;
                     }
 
@@ -817,7 +816,7 @@
 
             // under Linux we get a deadlock if we don't call this every once in a while
             if (nRequest % 25 == 0)
-                manager->wait();
+                manager->wait_grp(THREAD_GROUP);
             else
             {
                 // pause briefly (10ms) before checking again
@@ -826,8 +825,8 @@
             }
         }
 
-        // make sure the manager is in a good state
-        manager->wait();
+        // make sure all threads in the group have completed
+        manager->wait_grp(THREAD_GROUP);
 
         // done with the tile indices
         delete [] tileRows;



More information about the mapguide-commits mailing list