From 3893dff94f077728f62f0cf24253c18b70a19b53 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 20 May 2015 16:59:10 -0700 Subject: [PATCH] Renaming the PendingChanges --- libraries/render/src/render/Scene.cpp | 32 +++++++++++++-------------- libraries/render/src/render/Scene.h | 16 +++++++------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/libraries/render/src/render/Scene.cpp b/libraries/render/src/render/Scene.cpp index dad437dd13..ad4a27e091 100644 --- a/libraries/render/src/render/Scene.cpp +++ b/libraries/render/src/render/Scene.cpp @@ -12,21 +12,21 @@ using namespace render; -void Scene::ChangeBatch::resetItem(ID id, PayloadPointer& payload) { +void Scene::PendingChanges::resetItem(ID id, PayloadPointer& payload) { _resetItems.push_back(id); _resetPayloads.push_back(payload); } -void Scene::ChangeBatch::removeItem(ID id) { +void Scene::PendingChanges::removeItem(ID id) { _removedItems.push_back(id); } -void Scene::ChangeBatch::moveItem(ID id) { +void Scene::PendingChanges::moveItem(ID id) { _movedItems.push_back(id); } -void Scene::ChangeBatch::mergeBatch(ChangeBatch& newBatch) { +void Scene::PendingChanges::mergeBatch(PendingChanges& newBatch) { _resetItems.insert(_resetItems.end(), newBatch._resetItems.begin(), newBatch._resetItems.end()); _resetPayloads.insert(_resetPayloads.end(), newBatch._resetPayloads.begin(), newBatch._resetPayloads.end()); _removedItems.insert(_removedItems.end(), newBatch._removedItems.begin(), newBatch._removedItems.end()); @@ -44,24 +44,24 @@ Item::ID Scene::allocateID() { } /// Enqueue change batch to the scene -void Scene::enqueueChangeBatch(const ChangeBatch& changeBatch) { +void Scene::enqueuePendingChanges(const PendingChanges& pendingChanges) { _changeQueueMutex.lock(); - _changeQueue.push(changeBatch); + _changeQueue.push(pendingChanges); _changeQueueMutex.unlock(); } -void consolidateChangeQueue(Scene::ChangeBatchQueue& queue, Scene::ChangeBatch& singleBatch) { +void consolidateChangeQueue(Scene::PendingChangesQueue& queue, Scene::PendingChanges& singleBatch) { while (!queue.empty()) { - auto changeBatch = queue.front(); - singleBatch.mergeBatch(changeBatch); + auto pendingChanges = queue.front(); + singleBatch.mergeBatch(pendingChanges); queue.pop(); }; } -void Scene::processChangeBatchQueue() { +void Scene::processPendingChangesQueue() { _changeQueueMutex.lock(); - ChangeBatch consolidatedChangeBatch; - consolidateChangeQueue(_changeQueue, consolidatedChangeBatch); + PendingChanges consolidatedPendingChanges; + consolidateChangeQueue(_changeQueue, consolidatedPendingChanges); _changeQueueMutex.unlock(); _itemsMutex.lock(); @@ -72,10 +72,10 @@ void Scene::processChangeBatchQueue() { _items.resize(maxID + 100); // allocate the maxId and more } // Now we know for sure that we have enough items in the array to - // capture anything coming from the changeBatch - resetItems(consolidatedChangeBatch._resetItems, consolidatedChangeBatch._resetPayloads); - removeItems(consolidatedChangeBatch._removedItems); - moveItems(consolidatedChangeBatch._movedItems); + // capture anything coming from the pendingChanges + resetItems(consolidatedPendingChanges._resetItems, consolidatedPendingChanges._resetPayloads); + removeItems(consolidatedPendingChanges._removedItems); + moveItems(consolidatedPendingChanges._movedItems); // ready to go back to rendering activities _itemsMutex.unlock(); diff --git a/libraries/render/src/render/Scene.h b/libraries/render/src/render/Scene.h index cb0811d712..ad4f60ddc8 100644 --- a/libraries/render/src/render/Scene.h +++ b/libraries/render/src/render/Scene.h @@ -161,16 +161,16 @@ public: typedef std::shared_ptr< Observer > ObserverPointer; typedef std::vector< ObserverPointer > Observers; - class ChangeBatch { + class PendingChanges { public: - ChangeBatch() {} - ~ChangeBatch(); + PendingChanges() {} + ~PendingChanges(); void resetItem(ID id, PayloadPointer& payload); void removeItem(ID id); void moveItem(ID id); - void mergeBatch(ChangeBatch& newBatch); + void mergeBatch(PendingChanges& newBatch); Payloads _resetPayloads; ItemIDs _resetItems; @@ -179,7 +179,7 @@ public: protected: }; - typedef std::queue ChangeBatchQueue; + typedef std::queue PendingChangesQueue; Scene(); ~Scene() {} @@ -188,7 +188,7 @@ public: ID allocateID(); /// Enqueue change batch to the scene - void enqueueChangeBatch(const ChangeBatch& changeBatch); + void enqueuePendingChanges(const PendingChanges& pendingChanges); /// Scene Observer listen to any change and get notified void registerObserver(ObserverPointer& observer); @@ -198,7 +198,7 @@ protected: // Thread safe elements that can be accessed from anywhere std::atomic _IDAllocator; std::mutex _changeQueueMutex; - ChangeBatchQueue _changeQueue; + PendingChangesQueue _changeQueue; // The actual database // database of items is protected for editing by a mutex @@ -206,7 +206,7 @@ protected: Items _items; ItemLists _buckets; - void processChangeBatchQueue(); + void processPendingChangesQueue(); void resetItems(const ItemIDs& ids, Payloads& payloads); void removeItems(const ItemIDs& ids); void moveItems(const ItemIDs& ids);