mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-17 14:20:45 +02:00
Renaming the PendingChanges
This commit is contained in:
parent
2ed7aae8d5
commit
3893dff94f
2 changed files with 24 additions and 24 deletions
|
@ -12,21 +12,21 @@
|
||||||
|
|
||||||
using namespace render;
|
using namespace render;
|
||||||
|
|
||||||
void Scene::ChangeBatch::resetItem(ID id, PayloadPointer& payload) {
|
void Scene::PendingChanges::resetItem(ID id, PayloadPointer& payload) {
|
||||||
_resetItems.push_back(id);
|
_resetItems.push_back(id);
|
||||||
_resetPayloads.push_back(payload);
|
_resetPayloads.push_back(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::ChangeBatch::removeItem(ID id) {
|
void Scene::PendingChanges::removeItem(ID id) {
|
||||||
_removedItems.push_back(id);
|
_removedItems.push_back(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::ChangeBatch::moveItem(ID id) {
|
void Scene::PendingChanges::moveItem(ID id) {
|
||||||
_movedItems.push_back(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());
|
_resetItems.insert(_resetItems.end(), newBatch._resetItems.begin(), newBatch._resetItems.end());
|
||||||
_resetPayloads.insert(_resetPayloads.end(), newBatch._resetPayloads.begin(), newBatch._resetPayloads.end());
|
_resetPayloads.insert(_resetPayloads.end(), newBatch._resetPayloads.begin(), newBatch._resetPayloads.end());
|
||||||
_removedItems.insert(_removedItems.end(), newBatch._removedItems.begin(), newBatch._removedItems.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
|
/// Enqueue change batch to the scene
|
||||||
void Scene::enqueueChangeBatch(const ChangeBatch& changeBatch) {
|
void Scene::enqueuePendingChanges(const PendingChanges& pendingChanges) {
|
||||||
_changeQueueMutex.lock();
|
_changeQueueMutex.lock();
|
||||||
_changeQueue.push(changeBatch);
|
_changeQueue.push(pendingChanges);
|
||||||
_changeQueueMutex.unlock();
|
_changeQueueMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void consolidateChangeQueue(Scene::ChangeBatchQueue& queue, Scene::ChangeBatch& singleBatch) {
|
void consolidateChangeQueue(Scene::PendingChangesQueue& queue, Scene::PendingChanges& singleBatch) {
|
||||||
while (!queue.empty()) {
|
while (!queue.empty()) {
|
||||||
auto changeBatch = queue.front();
|
auto pendingChanges = queue.front();
|
||||||
singleBatch.mergeBatch(changeBatch);
|
singleBatch.mergeBatch(pendingChanges);
|
||||||
queue.pop();
|
queue.pop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::processChangeBatchQueue() {
|
void Scene::processPendingChangesQueue() {
|
||||||
_changeQueueMutex.lock();
|
_changeQueueMutex.lock();
|
||||||
ChangeBatch consolidatedChangeBatch;
|
PendingChanges consolidatedPendingChanges;
|
||||||
consolidateChangeQueue(_changeQueue, consolidatedChangeBatch);
|
consolidateChangeQueue(_changeQueue, consolidatedPendingChanges);
|
||||||
_changeQueueMutex.unlock();
|
_changeQueueMutex.unlock();
|
||||||
|
|
||||||
_itemsMutex.lock();
|
_itemsMutex.lock();
|
||||||
|
@ -72,10 +72,10 @@ void Scene::processChangeBatchQueue() {
|
||||||
_items.resize(maxID + 100); // allocate the maxId and more
|
_items.resize(maxID + 100); // allocate the maxId and more
|
||||||
}
|
}
|
||||||
// Now we know for sure that we have enough items in the array to
|
// Now we know for sure that we have enough items in the array to
|
||||||
// capture anything coming from the changeBatch
|
// capture anything coming from the pendingChanges
|
||||||
resetItems(consolidatedChangeBatch._resetItems, consolidatedChangeBatch._resetPayloads);
|
resetItems(consolidatedPendingChanges._resetItems, consolidatedPendingChanges._resetPayloads);
|
||||||
removeItems(consolidatedChangeBatch._removedItems);
|
removeItems(consolidatedPendingChanges._removedItems);
|
||||||
moveItems(consolidatedChangeBatch._movedItems);
|
moveItems(consolidatedPendingChanges._movedItems);
|
||||||
|
|
||||||
// ready to go back to rendering activities
|
// ready to go back to rendering activities
|
||||||
_itemsMutex.unlock();
|
_itemsMutex.unlock();
|
||||||
|
|
|
@ -161,16 +161,16 @@ public:
|
||||||
typedef std::shared_ptr< Observer > ObserverPointer;
|
typedef std::shared_ptr< Observer > ObserverPointer;
|
||||||
typedef std::vector< ObserverPointer > Observers;
|
typedef std::vector< ObserverPointer > Observers;
|
||||||
|
|
||||||
class ChangeBatch {
|
class PendingChanges {
|
||||||
public:
|
public:
|
||||||
ChangeBatch() {}
|
PendingChanges() {}
|
||||||
~ChangeBatch();
|
~PendingChanges();
|
||||||
|
|
||||||
void resetItem(ID id, PayloadPointer& payload);
|
void resetItem(ID id, PayloadPointer& payload);
|
||||||
void removeItem(ID id);
|
void removeItem(ID id);
|
||||||
void moveItem(ID id);
|
void moveItem(ID id);
|
||||||
|
|
||||||
void mergeBatch(ChangeBatch& newBatch);
|
void mergeBatch(PendingChanges& newBatch);
|
||||||
|
|
||||||
Payloads _resetPayloads;
|
Payloads _resetPayloads;
|
||||||
ItemIDs _resetItems;
|
ItemIDs _resetItems;
|
||||||
|
@ -179,7 +179,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
typedef std::queue<ChangeBatch> ChangeBatchQueue;
|
typedef std::queue<PendingChanges> PendingChangesQueue;
|
||||||
|
|
||||||
Scene();
|
Scene();
|
||||||
~Scene() {}
|
~Scene() {}
|
||||||
|
@ -188,7 +188,7 @@ public:
|
||||||
ID allocateID();
|
ID allocateID();
|
||||||
|
|
||||||
/// Enqueue change batch to the scene
|
/// 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
|
/// Scene Observer listen to any change and get notified
|
||||||
void registerObserver(ObserverPointer& observer);
|
void registerObserver(ObserverPointer& observer);
|
||||||
|
@ -198,7 +198,7 @@ protected:
|
||||||
// Thread safe elements that can be accessed from anywhere
|
// Thread safe elements that can be accessed from anywhere
|
||||||
std::atomic<unsigned int> _IDAllocator;
|
std::atomic<unsigned int> _IDAllocator;
|
||||||
std::mutex _changeQueueMutex;
|
std::mutex _changeQueueMutex;
|
||||||
ChangeBatchQueue _changeQueue;
|
PendingChangesQueue _changeQueue;
|
||||||
|
|
||||||
// The actual database
|
// The actual database
|
||||||
// database of items is protected for editing by a mutex
|
// database of items is protected for editing by a mutex
|
||||||
|
@ -206,7 +206,7 @@ protected:
|
||||||
Items _items;
|
Items _items;
|
||||||
ItemLists _buckets;
|
ItemLists _buckets;
|
||||||
|
|
||||||
void processChangeBatchQueue();
|
void processPendingChangesQueue();
|
||||||
void resetItems(const ItemIDs& ids, Payloads& payloads);
|
void resetItems(const ItemIDs& ids, Payloads& payloads);
|
||||||
void removeItems(const ItemIDs& ids);
|
void removeItems(const ItemIDs& ids);
|
||||||
void moveItems(const ItemIDs& ids);
|
void moveItems(const ItemIDs& ids);
|
||||||
|
|
Loading…
Reference in a new issue