Commit 11f1805e authored by Jakob Weiss's avatar Jakob Weiss
Browse files

QtJobProcessor doc / cleanup

parent 1f8a8832
...@@ -49,8 +49,6 @@ namespace campvis { ...@@ -49,8 +49,6 @@ namespace campvis {
{ {
tgtAssert(job, "Job must not be null!"); tgtAssert(job, "Job must not be null!");
std::cout << "Job processed." << std::endl;
(*job)(); (*job)();
delete job; delete job;
} }
......
...@@ -34,7 +34,17 @@ namespace campvis { ...@@ -34,7 +34,17 @@ namespace campvis {
/** /**
* Job processor class for campvis * This job processor singleton can be used to execute jobs (asynchronously) from inside the Qt GUI thread.
* This can result in simpler and better understandable code when only a few lines of code need
* to be executed in the context, as it removes the need to introduce a new signal and slot just
* to transition into the Qt GUI thread.
*
* Example:
* \code
* QtJobProc.enqueueJob([=](){
* _application->_mainWindow->statusBar()->showMessage(QString::fromStdString(status), timeout);
* });
* \endcode
*/ */
class QtJobProcessor : public QWidget, public tgt::Singleton<QtJobProcessor> { class QtJobProcessor : public QWidget, public tgt::Singleton<QtJobProcessor> {
Q_OBJECT; Q_OBJECT;
...@@ -45,8 +55,14 @@ namespace campvis { ...@@ -45,8 +55,14 @@ namespace campvis {
virtual ~QtJobProcessor(); virtual ~QtJobProcessor();
/**
Enqueues a new job to be processed by the job processor
*/
void enqueueJob(AbstractJob * job); void enqueueJob(AbstractJob * job);
/**
Convenience function to simplify the code, removing the necessity for a makeJobOnHeap() call
*/
void enqueueJob(std::function<void(void)> fn); void enqueueJob(std::function<void(void)> fn);
signals: signals:
......
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