Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 61d44af5 authored by schultezub's avatar schultezub
Browse files

some documentation

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@253 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 5d20ee70
......@@ -63,17 +63,17 @@ namespace TUMVis {
_startTimeCurrentContext = clock() * 1000 / CLOCKS_PER_SEC;
tgt::GLCanvas* context = _contexts[i];
// std::map<tgt::GLCanvas*, PerContextJobQueue*>::const_iterator a = _contextQueueMap.find(context);
// if (a == _contextQueueMap.end()) {
tbb::concurrent_hash_map<tgt::GLCanvas*, PerContextJobQueue*>::const_accessor a;
if (!_contextQueueMap.find(a, context)) {
tgtAssert(false, "Should not reach this: Did not find context in contextQueueMap!");
break;
}
// avoid expensive context-switches for contexts without oending jobs.
if (a->second->empty())
continue;
// perform context switch if necessary
if (_currentContext != context) {
if (_currentContext != 0) {
glFinish();
......@@ -126,8 +126,6 @@ namespace TUMVis {
}
void OpenGLJobProcessor::enqueueJob(tgt::GLCanvas* canvas, AbstractJob* job, JobType priority) {
// find the corresponding JobQueue for the context and update it:
//std::map<tgt::GLCanvas*, PerContextJobQueue*>::const_iterator a = _contextQueueMap.find(canvas);
tbb::concurrent_hash_map<tgt::GLCanvas*, PerContextJobQueue*>::const_accessor a;
if (_contextQueueMap.find(a, canvas)) {
switch (priority) {
......@@ -156,9 +154,6 @@ namespace TUMVis {
void OpenGLJobProcessor::registerContext(tgt::GLCanvas* context) {
#ifdef TUMVIS_DEBUG
//tbb::concurrent_hash_map<tgt::GLCanvas*, PerContextJobQueue*>::const_accessor a;
// std::map<tgt::GLCanvas*, PerContextJobQueue*>::iterator a = _contextQueueMap.find(context);
// if (a != _contextQueueMap.end())
tbb::concurrent_hash_map<tgt::GLCanvas*, PerContextJobQueue*>::const_accessor a;
if (_contextQueueMap.find(a, context))
tgtAssert(false, "Contexts shall only be registered once!");
......
......@@ -48,8 +48,7 @@ namespace tgt {
namespace TUMVis {
/**
*
* \todo Check if the inheritance of PriorityPool is a cool design or not...
* \todo Explain scheduling technique.
*/
class OpenGLJobProcessor : public tgt::Singleton<OpenGLJobProcessor>, public Runnable, public sigslot::has_slots<> {
friend class tgt::Singleton<OpenGLJobProcessor>;
......@@ -59,7 +58,7 @@ namespace TUMVis {
* Enumeration of the different priorities of items.
*/
enum JobType {
PaintJob, ///< PaintJobs have the highest priority
PaintJob, ///< PaintJobs have the highest priority, there can only be one paint job per context at a time.
SerialJob, ///< SerialJobs have a lower priority than PaintJobs, but are guaranteed to be executed in order.
LowPriorityJob ///< Low priority jobs have the lowest priority, can be executed at any time. The only guarantee is that thay won't starve.
};
......@@ -67,13 +66,17 @@ namespace TUMVis {
virtual ~OpenGLJobProcessor();
/**
* Registers the given OpenGL context, so that it gets its own job queue.
* \param context OpenGL context to register.
*/
void registerContext(tgt::GLCanvas* context);
/// \see Runnable::stop
void stop();
/**
* Performs the pipeline evaluation using conditional wait.
* Performs the job processing using conditional wait.
* \sa Runnable::run
*/
void run();
......@@ -82,6 +85,7 @@ namespace TUMVis {
* Enqueues the given Job with the given priority.
*
* \note OpenGLJobProcessor takes ownership of \a job.
* \param canvas OpenGL context for which to enqueue the job, must be registered.
* \param job Job to enqueue, PriorityPool takes ownership of this Job!
* \param priority Priority of the job to enqueue
*/
......@@ -89,16 +93,26 @@ namespace TUMVis {
protected:
/**
* Struct encapsulating the job queue for a single OpenGL context.
*/
struct PerContextJobQueue {
/**
* Creates an empty PerContextJobQueue.
*/
PerContextJobQueue()
: _paintJob(0)
{
}
AbstractJob* _paintJob;
tbb::concurrent_queue<AbstractJob*> _serialJobs;
tbb::concurrent_queue<AbstractJob*> _lowPriorityJobs;
AbstractJob* _paintJob; ///< PaintJob of the context
tbb::concurrent_queue<AbstractJob*> _serialJobs; ///< Queue of serial jobs for the context
tbb::concurrent_queue<AbstractJob*> _lowPriorityJobs; ///< Queue of jow priority jobs for the context
/**
* Checks, whether there is any job to do for this context.
* \return (_serialJobs.empty() && _lowPriorityJobs.empty() && (_paintJob == 0))
*/
bool empty() const {
return (_serialJobs.empty() && _lowPriorityJobs.empty() && (_paintJob == 0));
}
......
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