Commit 6ade6e78 authored by schultezub's avatar schultezub
Browse files

Fixed bug that Processor's invalidations get lost when processor is locked

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@465 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent fc707dcd
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "tgt/logmanager.h" #include "tgt/logmanager.h"
#include "tbb/spin_mutex.h" #include "tbb/spin_mutex.h"
#include "tbb/mutex.h" #include "tbb/mutex.h"
#include "core/tools/invalidationlevel.h"
#include "core/datastructures/datacontainer.h" #include "core/datastructures/datacontainer.h"
#include "core/properties/propertycollection.h" #include "core/properties/propertycollection.h"
......
...@@ -68,7 +68,13 @@ namespace campvis { ...@@ -68,7 +68,13 @@ namespace campvis {
void AbstractProcessor::unlockProcessor() { void AbstractProcessor::unlockProcessor() {
tgtAssert(_locked == true, "Called AbstractProcessor::unlockProcessor() on unlocked processor!"); tgtAssert(_locked == true, "Called AbstractProcessor::unlockProcessor() on unlocked processor!");
unlockAllProperties(); unlockAllProperties();
int summed = VALID;
int il;
while (_queuedInvalidations.try_pop(il)) {
summed |= il;
}
_locked = false; _locked = false;
invalidate(summed);
} }
bool AbstractProcessor::isLocked() { bool AbstractProcessor::isLocked() {
...@@ -89,11 +95,17 @@ namespace campvis { ...@@ -89,11 +95,17 @@ namespace campvis {
} }
void AbstractProcessor::invalidate(int level) { void AbstractProcessor::invalidate(int level) {
int tmp; if (_locked) {
do { // TODO: this is not 100% thread-safe - an invalidation might slip through if the processor is unlocked during invalidation
tmp = _level; _queuedInvalidations.push(level);
} while (_level.compare_and_swap(tmp | level, tmp) != tmp); }
s_invalidated(this); else {
int tmp;
do {
tmp = _level;
} while (_level.compare_and_swap(tmp | level, tmp) != tmp);
s_invalidated(this);
}
} }
void AbstractProcessor::validate(int level) { void AbstractProcessor::validate(int level) {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "sigslot/sigslot.h" #include "sigslot/sigslot.h"
#include "tbb/atomic.h" #include "tbb/atomic.h"
#include "tbb/concurrent_queue.h"
#include "tgt/logmanager.h" #include "tgt/logmanager.h"
#include "core/datastructures/datacontainer.h" #include "core/datastructures/datacontainer.h"
#include "core/properties/propertycollection.h" #include "core/properties/propertycollection.h"
...@@ -250,7 +251,8 @@ namespace campvis { ...@@ -250,7 +251,8 @@ namespace campvis {
tbb::atomic<bool> _locked; tbb::atomic<bool> _locked;
private: private:
tbb::atomic<int> _level; ///< current invalidation level tbb::atomic<int> _level; ///< current invalidation level
tbb::concurrent_queue<int> _queuedInvalidations;
static const std::string loggerCat_; static const std::string loggerCat_;
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment