| 2678 | } |
| 2679 | |
| 2680 | bool NpScene::startRead() const |
| 2681 | { |
| 2682 | if (mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK) |
| 2683 | { |
| 2684 | ThreadReadWriteCount localCounts (TlsGetValue(mThreadReadWriteDepth)); |
| 2685 | |
| 2686 | // ensure we already have the write or read lock |
| 2687 | return localCounts.writeLockDepth > 0 || localCounts.readLockDepth > 0; |
| 2688 | } |
| 2689 | else |
| 2690 | { |
| 2691 | Ps::atomicIncrement(&mConcurrentReadCount); |
| 2692 | |
| 2693 | // update current threads read depth |
| 2694 | ThreadReadWriteCount localCounts (TlsGetValue(mThreadReadWriteDepth)); |
| 2695 | localCounts.readDepth++; |
| 2696 | TlsSetValue(mThreadReadWriteDepth, localCounts.getData()); |
| 2697 | |
| 2698 | // success if the current thread is already performing a write (API re-entry) or no writes are in progress |
| 2699 | bool success = (localCounts.writeDepth > 0 || mConcurrentWriteCount == 0); |
| 2700 | |
| 2701 | if (!success) |
| 2702 | Ps::atomicIncrement(&mConcurrentErrorCount); |
| 2703 | |
| 2704 | return success; |
| 2705 | } |
| 2706 | } |
| 2707 | |
| 2708 | void NpScene::stopRead() const |
| 2709 | { |
no test coverage detected