pipelineevaluator.cpp 1.26 KB
Newer Older
1
2
3
4
5
6
7
8
#include "pipelineevaluator.h"

namespace TUMVis {
    const std::string PipelineEvaluator::loggerCat_ = "TUMVis.core.pipeline.PipelineEvaluator";


    PipelineEvaluator::PipelineEvaluator(AbstractPipeline* pipeline)
        : _pipeline(pipeline)
9
        , _evaluationThread()
10
11
    {
        tgtAssert(pipeline != 0, "Pipeline must not be 0.");
12
        _evaluatePipeline = false;
13
14
15
16
17
        pipeline->s_PipelineInvalidated.connect(this, &PipelineEvaluator::OnPipelineInvalidated);
    }

    PipelineEvaluator::~PipelineEvaluator() {
        _pipeline->s_PipelineInvalidated.disconnect(this);
18

19
20
21
22
    }

    void PipelineEvaluator::startEvaluation() {
        _evaluatePipeline = true;
23
        std::unique_lock<tbb::mutex> lock(_pipeline->_evaluationMutex);
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

        while (_evaluatePipeline) {
            _pipeline->execute();

            while (_evaluatePipeline && _pipeline->getInvalidationLevel().isValid())
                _evaluationCondition.wait(lock);
        }
    }

    void PipelineEvaluator::stopEvaluation() {
        _evaluatePipeline = false;
        _evaluationCondition.notify_all();
    }

    void PipelineEvaluator::OnPipelineInvalidated() {
        if (_evaluatePipeline)
            _evaluationCondition.notify_all();
    }

}