Commit ab290c65 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Various fixes:

* campvis::deinit() also deinitializes PipelineFactory and ProcessorFactory
* Fixed signal_manager::waitForSignalQueueFlushed() returning too early -> fixes occasionally failing AbstractProcessorTest
* Fixed signal_manager::waitForSignalQueueFlushed() waiting for ever in case that the wake-up of signal_manager fails
parent d31bbb33
......@@ -34,6 +34,8 @@
#include "cgt/qt/qtthreadedcanvas.h"
#include "core/datastructures/imagerepresentationconverter.h"
#include "core/pipeline/pipelinefactory.h"
#include "core/pipeline/processorfactory.h"
#include "core/tools/quadrenderer.h"
#include "core/tools/simplejobprocessor.h"
......@@ -85,7 +87,8 @@ namespace campvis {
SimpleJobProcessor::deinit();
ImageRepresentationConverter::deinit();
//PipelineFactory::deinit();
PipelineFactory::deinit();
ProcessorFactory::deinit();
}
CAMPVIS_CORE_API std::string completePath(const std::string& filename) {
......
......@@ -102,11 +102,8 @@ namespace sigslot {
// nothing to wait for if current thread is signal_manager's thread.
if (isCurrentThreadSignalManagerThread())
return;
// nothing to wait for if the signal queue is already empty.
if (_signalQueue.empty())
return;
// signal used to detect that the signal queue has been flushed
class SIGSLOT_API flushed_signal : public _signal_handle_base {
public:
flushed_signal(bool* ptr)
......@@ -125,8 +122,13 @@ namespace sigslot {
bool signalVariable = false;
this->queueSignalImpl(new flushed_signal(&signalVariable));
while (! signalVariable)
std::this_thread::yield(); // so we do some busy waiting here - hopefully not too long...
while (! signalVariable) {
// so we do some busy waiting here - hopefully not too long...
std::this_thread::yield();
// make sure that the signal_manager thread is actually running, otherwise we wait forever.
_evaluationCondition.notify_all();
}
}
const std::string signal_manager::loggerCat_;
......
......@@ -361,15 +361,15 @@ namespace sigslot {
/// Typedef for the signal queue
typedef tbb::concurrent_queue<_signal_handle_base*> SignalQueue;
/// Typedef for signal pool's allocator
typedef std::allocator<_signal_handle_base> pool_allocator_t;
SignalHandlingMode _handlingMode; ///< Mode for handling signals
SignalQueue _signalQueue; ///< Queue for signals to be dispatched
tbb::memory_pool<pool_allocator_t> _signalPool; ///< Memory pool for the signals
std::mutex _ecMutex; ///< Mutex for protecting _evaluationCondition
std::thread::id _this_thread_id;
typedef std::allocator<_signal_handle_base> pool_allocator_t;
tbb::memory_pool<pool_allocator_t> _signalPool; ///< Memory pool for the signals
std::thread::id _this_thread_id; ///< Thread ID of signal_manager thread
static const std::string loggerCat_;
};
......
......@@ -48,15 +48,17 @@ public:
~DummyTestProcessor () {}
virtual const std::string getName() const { return "DummyTestProcessor"; };
virtual const std::string getDescription() const { return "A dummy processor for the testing purposes only."; };
virtual const std::string getAuthor() const { return "Hossain Mahmud <mahmud@in.tum.de>"; };
virtual ProcessorState getProcessorState() const { return AbstractProcessor::TESTING; };
virtual const std::string getName() const override { return "DummyTestProcessor"; };
virtual const std::string getDescription() const override { return "A dummy processor for the testing purposes only."; };
virtual const std::string getAuthor() const override { return "Hossain Mahmud <mahmud@in.tum.de>"; };
virtual ProcessorState getProcessorState() const override { return AbstractProcessor::TESTING; };
virtual void updateResult(DataContainer& dataContainer) {
virtual void updateResult(DataContainer& dataContainer) override {
if (_togglePropertyDuringProcess) {
bool currentValue = _boolProperty.getValue();
_boolProperty.setValue(! currentValue);
std::cout << "set to: " << !currentValue << "\n";
}
}
......@@ -98,25 +100,29 @@ TEST_F(AbstractProcessorTest, invalidationTest) {
this->_processor1.invalidate(AbstractProcessor::INVALID_RESULT);
this->_processor1._togglePropertyDuringProcess = false;
this->_processor1.process(this->_dataContainer);
sigslot::signal_manager::getRef().waitForSignalQueueFlushed();
EXPECT_EQ(AbstractProcessor::VALID, this->_processor1.getInvalidationLevel());
}
/**
* Tests processor's locking mechanism
*/
TEST_F(AbstractProcessorTest, lockingTest) {
/* --- */
this->_processor1.invalidate(AbstractProcessor::INVALID_RESULT);
this->_processor1._togglePropertyDuringProcess = true;
this->_processor1.process(this->_dataContainer);
sigslot::signal_manager::getRef().waitForSignalQueueFlushed();
EXPECT_NE(AbstractProcessor::VALID, this->_processor1.getInvalidationLevel());
}
/**
* Tests processor's locking mechanism
*/
TEST_F(AbstractProcessorTest, lockingTest) {
bool currentValue = this->_processor1._boolProperty.getValue();
{
AbstractProcessor::ScopedLock lock(&this->_processor1);
bool currentValue = this->_processor1._boolProperty.getValue();
AbstractProcessor::ScopedLock lock(&this->_processor1);
this->_processor1._boolProperty.setValue(! currentValue);
EXPECT_EQ(currentValue, this->_processor1._boolProperty.getValue());
}
EXPECT_EQ(!currentValue, this->_processor1._boolProperty.getValue());
}
\ No newline at end of file
......@@ -90,11 +90,10 @@ GTEST_API_ int main(int argc, char **argv) {
std::thread testThread([&] () {
cgt::GLContextScopedLock lock(_localContext);
ret= RUN_ALL_TESTS();
app->exit();
});
testThread.join();
app->exit();
app->exec();
deinit();
delete app;
......
Markdown is supported
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