Changeset 46494 in vbox for trunk/src/libs/xpcom18a4/ipc/ipcd
- Timestamp:
- Jun 11, 2013 3:03:22 PM (12 years ago)
- Location:
- trunk/src/libs/xpcom18a4/ipc/ipcd/client
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/ipc/ipcd/client/src/ipcdclient.cpp
r46435 r46494 59 59 #include "pratom.h" 60 60 61 #ifdef VBOX 62 # include <iprt/critsect.h> 63 # define VBOX_WITH_IPCCLIENT_RW_CS 64 #endif 65 61 66 /* ------------------------------------------------------------------------- */ 62 67 … … 147 152 ~ipcClientState() 148 153 { 154 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 149 155 if (monitor) 150 156 nsAutoMonitor::DestroyMonitor(monitor); 151 } 152 157 #else 158 RTCritSectRwDelete(&critSect); 159 #endif 160 } 161 162 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 153 163 // 154 164 // the monitor protects the targetMap and the connected and shutdown flags. … … 160 170 // 161 171 PRMonitor *monitor; 172 #else /* VBOX_WITH_IPCCLIENT_RW_CS */ 173 RTCRITSECTRW critSect; 174 #endif /* VBOX_WITH_IPCCLIENT_RW_CS */ 162 175 ipcTargetMap targetMap; 163 176 PRBool connected; … … 172 185 173 186 ipcClientState() 187 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 174 188 : monitor(nsAutoMonitor::NewMonitor("ipcClientState")) 175 189 , connected(PR_FALSE) 190 #else 191 : connected(PR_FALSE) 192 #endif 176 193 , shutdown(PR_FALSE) 177 194 , selfID(0) 178 {} 195 { 196 #ifdef VBOX_WITH_IPCCLIENT_RW_CS 197 /* Not employing the lock validator here to keep performance up in debug builds. */ 198 RTCritSectRwInitEx(&critSect, RTCRITSECT_FLAGS_NO_LOCK_VAL, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, NULL); 199 #endif 200 } 179 201 }; 180 202 … … 186 208 return NULL; 187 209 210 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 188 211 if (!cs->monitor || !cs->targetMap.Init()) 212 #else 213 if (!RTCritSectRwIsInitialized(&cs->critSect) || !cs->targetMap.Init()) 214 #endif 189 215 { 190 216 delete cs; … … 202 228 GetTarget(const nsID &aTarget, ipcTargetData **td) 203 229 { 230 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 204 231 nsAutoMonitor mon(gClientState->monitor); 205 232 return gClientState->targetMap.Get(nsIDHashKey(&aTarget).GetKey(), td); 233 #else 234 RTCritSectRwEnterShared(&gClientState->critSect); 235 PRBool fRc = gClientState->targetMap.Get(nsIDHashKey(&aTarget).GetKey(), td); 236 RTCritSectRwLeaveShared(&gClientState->critSect); 237 return fRc; 238 #endif 206 239 } 207 240 … … 209 242 PutTarget(const nsID &aTarget, ipcTargetData *td) 210 243 { 244 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 211 245 nsAutoMonitor mon(gClientState->monitor); 212 246 return gClientState->targetMap.Put(nsIDHashKey(&aTarget).GetKey(), td); 247 #else 248 RTCritSectRwEnterExcl(&gClientState->critSect); 249 PRBool fRc = gClientState->targetMap.Put(nsIDHashKey(&aTarget).GetKey(), td); 250 RTCritSectRwLeaveExcl(&gClientState->critSect); 251 return fRc; 252 #endif 213 253 } 214 254 … … 216 256 DelTarget(const nsID &aTarget) 217 257 { 258 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 218 259 nsAutoMonitor mon(gClientState->monitor); 219 260 gClientState->targetMap.Remove(nsIDHashKey(&aTarget).GetKey()); 261 #else 262 RTCritSectRwEnterExcl(&gClientState->critSect); 263 gClientState->targetMap.Remove(nsIDHashKey(&aTarget).GetKey()); 264 RTCritSectRwLeaveExcl(&gClientState->critSect); 265 #endif 220 266 } 221 267 … … 805 851 // all targets but IPCM will not be able to use WaitTarget any more. 806 852 853 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 807 854 nsAutoMonitor mon(gClientState->monitor); 855 #else 856 RTCritSectRwEnterExcl(&gClientState->critSect); 857 #endif 858 808 859 gClientState->shutdown = PR_TRUE; 809 860 gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndNotify, nsnull); 861 862 #ifdef VBOX_WITH_IPCCLIENT_RW_CS 863 RTCritSectRwLeaveExcl(&gClientState->critSect); 864 #endif 810 865 } 811 866 … … 1290 1345 // unblock any calls to WaitTarget. 1291 1346 1347 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 1292 1348 nsAutoMonitor mon(gClientState->monitor); 1349 #else 1350 RTCritSectRwEnterExcl(&gClientState->critSect); 1351 #endif 1352 1293 1353 gClientState->connected = PR_FALSE; 1294 1354 gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndNotify, nsnull); 1355 1356 #ifdef VBOX_WITH_IPCCLIENT_RW_CS 1357 RTCritSectRwLeaveExcl(&gClientState->critSect); 1358 #endif 1295 1359 } 1296 1360 … … 1393 1457 // targets) giving them an opportuninty to finish wait cycle because of 1394 1458 // the peer client death, when appropriate. 1459 #ifndef VBOX_WITH_IPCCLIENT_RW_CS 1395 1460 nsAutoMonitor mon(gClientState->monitor); 1461 #else 1462 RTCritSectRwEnterShared(&gClientState->critSect); 1463 #endif 1464 1396 1465 gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndPlaceMsg, msg); 1397 1466 1467 #ifdef VBOX_WITH_IPCCLIENT_RW_CS 1468 RTCritSectRwLeaveShared(&gClientState->critSect); 1469 #endif 1398 1470 delete msg; 1399 1471
Note:
See TracChangeset
for help on using the changeset viewer.