| 2628 | } |
| 2629 | |
| 2630 | bool NpScene::startRead() const |
| 2631 | { |
| 2632 | if (mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK) |
| 2633 | { |
| 2634 | ThreadReadWriteCount localCounts (TlsGetValue(mThreadReadWriteDepth)); |
| 2635 | |
| 2636 | // ensure we already have the write or read lock |
| 2637 | return localCounts.writeLockDepth > 0 || localCounts.readLockDepth > 0; |
| 2638 | } |
| 2639 | else |
| 2640 | { |
| 2641 | Ps::atomicIncrement(&mConcurrentReadCount); |
| 2642 | |
| 2643 | // update current threads read depth |
| 2644 | ThreadReadWriteCount localCounts (TlsGetValue(mThreadReadWriteDepth)); |
| 2645 | localCounts.readDepth++; |
| 2646 | TlsSetValue(mThreadReadWriteDepth, localCounts.getData()); |
| 2647 | |
| 2648 | // success if the current thread is already performing a write (API re-entry) or no writes are in progress |
| 2649 | bool success = (localCounts.writeDepth > 0 || mConcurrentWriteCount == 0); |
| 2650 | |
| 2651 | if (!success) |
| 2652 | Ps::atomicIncrement(&mConcurrentErrorCount); |
| 2653 | |
| 2654 | return success; |
| 2655 | } |
| 2656 | } |
| 2657 | |
| 2658 | void NpScene::stopRead() const |
| 2659 | { |
no test coverage detected