| 2708 | } |
| 2709 | |
| 2710 | void NpScene::lockWrite(const char* file, PxU32 line) |
| 2711 | { |
| 2712 | // increment this threads write depth |
| 2713 | ThreadReadWriteCount localCounts (TlsGetValue(mThreadReadWriteDepth)); |
| 2714 | if (localCounts.writeLockDepth == 0 && localCounts.readLockDepth > 0) |
| 2715 | { |
| 2716 | Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, file?file:__FILE__, file?int(line):__LINE__, "PxScene::lockWrite() detected after a PxScene::lockRead(), lock upgrading is not supported, behaviour will be undefined."); |
| 2717 | return; |
| 2718 | } |
| 2719 | localCounts.writeLockDepth++; |
| 2720 | TlsSetValue(mThreadReadWriteDepth, localCounts.getData()); |
| 2721 | |
| 2722 | // only lock on first call |
| 2723 | if (localCounts.writeLockDepth == 1) |
| 2724 | mRWLock.lockWriter(); |
| 2725 | |
| 2726 | PX_ASSERT(mCurrentWriter == 0 || mCurrentWriter == Thread::getId()); |
| 2727 | |
| 2728 | // set ourselves as the current writer |
| 2729 | mCurrentWriter = Thread::getId(); |
| 2730 | } |
| 2731 | |
| 2732 | void NpScene::unlockWrite() |
| 2733 | { |
no test coverage detected