All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Protected Member Functions
SciFigs::LayerPainterThread Class Reference

Brief description of class still missing. More...

#include <LayerPainterThread.h>

Inheritance diagram for SciFigs::LayerPainterThread:
QGpCoreTools::Thread

List of all members.

Public Member Functions

LayerPainterRequestcurrentRequest () const
 LayerPainterThread (LayerPainter *parent)
void terminate ()

Protected Member Functions

virtual void run ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

  : Thread(parent), _parent(parent)
{
  _terminate=false;
  _currentRequest=0;
}

Member Function Documentation

{return _currentRequest;}
void SciFigs::LayerPainterThread::run ( ) [protected, virtual]

References SciFigs::LayerPainterRequest::paint(), QGpCoreTools::Thread::setSleeping(), and TRACE.

{
  // CRASH: segmentation fault reported under windows Vista while closing Figue
  TRACE;
  while(true) {
    while(true) {
      if(_terminate.testAndSetOrdered(true, true)) {
        return;
      }
      // Check for new layers to paint, if nothing to do, the thread goes in sleep mode
      _parent->_queueMutex.lock();
      if(_parent->_queue.isEmpty()) {
        _parent->_queueMutex.unlock();
        break;
      }
      _currentRequest=_parent->_queue.dequeue();
      _parent->_queueMutex.unlock();
      //printf("%s: start painting %p\n",objectName().toAscii().data(), _currentRequest->graphContent());
      _currentRequest->paint();
      //printf("%s: stop painting %p\n",objectName().toAscii().data(), _currentRequest->graphContent());
      LayerPainterRequest * r=_currentRequest;
      _parent->_queueMutex.lock();
      _currentRequest=0;
      _parent->_queueMutex.unlock();
      r->deleteLater();
    }
    _parent->_waitMutex.lock();
    //printf("%s: sleeping\n",objectName().toAscii().data());
    setSleeping(true);
    _parent->_paintEvent.wait(&_parent->_waitMutex);
    setSleeping(false);
    //printf("%s: waking up\n",objectName().toAscii().data());
    _parent->_waitMutex.unlock();
  }
}

References SciFigs::LayerPainterRequest::terminate().

{
  _terminate.fetchAndStoreOrdered(true);
  _parent->_queueMutex.lock();
  if(_currentRequest) _currentRequest->terminate();
  _parent->_queueMutex.unlock();
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines