PR comments

This commit is contained in:
Brad Davis 2015-09-10 20:55:06 -07:00
commit 92eeb564fe
5 changed files with 6 additions and 98 deletions

View file

@ -31,7 +31,7 @@ var TOTAL_ENTITIES = 100;
for (var i = 0; i < TOTAL_ENTITIES; i++) { for (var i = 0; i < TOTAL_ENTITIES; i++) {
var box = Entities.addEntity({ var box = Entities.addEntity({
type: "Box", type: "Box",
name: "" name: TEST_ENTITY_NAME,
position: { position: {
x: randInt(0, 100) - 50 + MyAvatar.position.x, x: randInt(0, 100) - 50 + MyAvatar.position.x,
y: randInt(0, 100) - 50 + MyAvatar.position.x, y: randInt(0, 100) - 50 + MyAvatar.position.x,

View file

@ -47,7 +47,7 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
glm::quat rotation; glm::quat rotation;
glm::vec3 position; glm::vec3 position;
glm::vec3 offset; glm::vec3 offset;
bool result = withTryReadLock([&]{ bool gotLock = withTryReadLock([&]{
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
glm::vec3 palmPosition; glm::vec3 palmPosition;
glm::quat palmRotation; glm::quat palmRotation;
@ -64,8 +64,8 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
position = palmPosition + offset; position = palmPosition + offset;
}); });
if (result) { if (gotLock) {
result = withTryWriteLock([&]{ gotLock = withTryWriteLock([&]{
if (_positionalTarget != position || _rotationalTarget != rotation) { if (_positionalTarget != position || _rotationalTarget != rotation) {
auto ownerEntity = _ownerEntity.lock(); auto ownerEntity = _ownerEntity.lock();
if (ownerEntity) { if (ownerEntity) {
@ -77,7 +77,7 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
}); });
} }
if (result) { if (gotLock) {
ObjectActionSpring::updateActionWorker(deltaTimeStep); ObjectActionSpring::updateActionWorker(deltaTimeStep);
} }
} }

View file

@ -1566,7 +1566,7 @@ bool EntityItem::updateAction(EntitySimulation* simulation, const QUuid& actionI
} }
bool EntityItem::removeAction(EntitySimulation* simulation, const QUuid& actionID) { bool EntityItem::removeAction(EntitySimulation* simulation, const QUuid& actionID) {
bool success; bool success = false;
withWriteLock([&] { withWriteLock([&] {
checkWaitingToRemove(simulation); checkWaitingToRemove(simulation);
success = removeActionInternal(actionID); success = removeActionInternal(actionID);

View file

@ -8,86 +8,3 @@
#include "ReadWriteLockable.h" #include "ReadWriteLockable.h"
#include <QtCore/QThread>
//
//bool ReadWriteLockable::isLocked() const {
// bool readSuccess = _lock.tryLockForRead();
// if (readSuccess) {
// _lock.unlock();
// }
// bool writeSuccess = _lock.tryLockForWrite();
// if (writeSuccess) {
// _lock.unlock();
// }
// if (readSuccess && writeSuccess) {
// return false; // if we can take both kinds of lock, there was no previous lock
// }
// return true; // either read or write failed, so there is some lock in place.
//}
//
//
//bool ReadWriteLockable::isWriteLocked() const {
// bool readSuccess = _lock.tryLockForRead();
// if (readSuccess) {
// _lock.unlock();
// return false;
// }
// bool writeSuccess = _lock.tryLockForWrite();
// if (writeSuccess) {
// _lock.unlock();
// return false;
// }
// return true; // either read or write failed, so there is some lock in place.
//}
//
//
//bool ReadWriteLockable::isUnlocked() const {
// // this can't be sure -- this may get unlucky and hit locks from other threads. what we're actually trying
// // to discover is if *this* thread hasn't locked the EntityItem. Try repeatedly to take both kinds of lock.
// bool readSuccess = false;
// for (int i = 0; i<80; i++) {
// readSuccess = _lock.tryLockForRead();
// if (readSuccess) {
// _lock.unlock();
// break;
// }
// QThread::usleep(200);
// }
//
// bool writeSuccess = false;
// if (readSuccess) {
// for (int i = 0; i<80; i++) {
// writeSuccess = _lock.tryLockForWrite();
// if (writeSuccess) {
// _lock.unlock();
// break;
// }
// QThread::usleep(300);
// }
// }
//
// if (readSuccess && writeSuccess) {
// return true; // if we can take both kinds of lock, there was no previous lock
// }
// return false;
//}
//
//void ReadWriteLockable::lockForRead() const {
// _lock.lockForRead();
//}
//
//bool ReadWriteLockable::tryLockForRead() const {
// return _lock.tryLockForRead();
//}
//
//void ReadWriteLockable::lockForWrite() {
// _lock.lockForWrite();
//}
//
//bool ReadWriteLockable::tryLockForWrite() {
// return _lock.tryLockForWrite();
//}
//
//void ReadWriteLockable::unlock() const {
// _lock.unlock();
//}

View file

@ -55,15 +55,6 @@ public:
return withReadLock(f, false); return withReadLock(f, false);
} }
// void lockForRead() const;
// bool tryLockForRead() const;
// void lockForWrite();
// bool tryLockForWrite();
// void unlock() const;
// // FIXME These functions should not be used
// bool isLocked() const;
// bool isWriteLocked() const;
// bool isUnlocked() const;
private: private:
mutable QReadWriteLock _lock{ QReadWriteLock::Recursive }; mutable QReadWriteLock _lock{ QReadWriteLock::Recursive };
}; };