diff --git a/src/server/Dispatcher.cpp b/src/server/Dispatcher.cpp index f6bdb41..67f883e 100644 --- a/src/server/Dispatcher.cpp +++ b/src/server/Dispatcher.cpp @@ -109,7 +109,7 @@ void DProcess::emitUpdate(){ // ================================ Dispatcher::Dispatcher(){ qRegisterMetaType("Dispatcher::PROC_QUEUE"); - connect(this, SIGNAL(mkprocs(Dispatcher::PROC_QUEUE, DProcess*)), this, SLOT(mkProcs(Dispatcher::PROC_QUEUE, DProcess*)) ); + //connect(this, SIGNAL(mkprocs(Dispatcher::PROC_QUEUE, DProcess*)), this, SLOT(mkProcs(Dispatcher::PROC_QUEUE, DProcess*)) ); } Dispatcher::~Dispatcher(){ @@ -117,6 +117,9 @@ Dispatcher::~Dispatcher(){ } void Dispatcher::start(QString queuefile){ + //Setup connections here (in case it was moved to different thread after creation) + connect(this, SIGNAL(mkprocs(Dispatcher::PROC_QUEUE, DProcess*)), this, SLOT(mkProcs(Dispatcher::PROC_QUEUE, DProcess*)) ); + connect(this, SIGNAL(checkProcs()), this, SLOT(checkQueues()) ); //load any previously-unrun processes // TO DO } @@ -141,7 +144,6 @@ DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QSt //For multi-threading, need to emit a signal/slot for this action (object creations need to be in same thread as parent) //qDebug() << "Queue Process:" << queue << ID << cmds; DProcess *P = createProcess(ID, cmds); - //connect(this, SIGNAL(mkprocs(Dispatcher::PROC_QUEUE, DProcess*)), this, SLOT(mkProcs(Dispatcher::PROC_QUEUE, DProcess*)) ); emit mkprocs(queue, P); return P; } @@ -165,7 +167,7 @@ void Dispatcher::mkProcs(Dispatcher::PROC_QUEUE queue, DProcess *P){ QList list; if(!HASH.contains(queue)){ HASH.insert(queue, list); } //insert an empty list HASH[queue] << P; //add this proc to the end of the list - CheckQueues(); + emit checkProcs(); } void Dispatcher::ProcFinished(QString ID, QJsonObject log){ @@ -180,7 +182,7 @@ void Dispatcher::ProcFinished(QString ID, QJsonObject log){ emit DispatchEvent(log); } - QTimer::singleShot(20,this, SLOT(CheckQueues()) ); + emit checkProcs(); } void Dispatcher::ProcUpdated(QString ID, QJsonObject log){ diff --git a/src/server/Dispatcher.h b/src/server/Dispatcher.h index 5b6761e..fdd9429 100644 --- a/src/server/Dispatcher.h +++ b/src/server/Dispatcher.h @@ -99,6 +99,7 @@ signals: //Signals for private usage void mkprocs(Dispatcher::PROC_QUEUE, DProcess*); + void checkProcs(); };