aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <Toni.Uhlig@tq-group.com>2017-12-04 16:11:58 +0100
committerToni Uhlig <Toni.Uhlig@tq-group.com>2017-12-04 16:11:58 +0100
commit2f7d624ef6eb97d6caf39ea58ec92ad848464a8a (patch)
tree65054d2a64788a16a9af6eb595dbff4d5a1b97c8 /src
parent986367293179c4836a044aa704b54d2491b4a76b (diff)
introduced new Event Job::eID_THREAD_JOB_DONE, which will be send after every job finishes
Diffstat (limited to 'src')
-rw-r--r--src/JobQueue.cpp3
-rw-r--r--src/JobQueue.hpp2
-rw-r--r--src/UpdateGUI.cpp22
3 files changed, 22 insertions, 5 deletions
diff --git a/src/JobQueue.cpp b/src/JobQueue.cpp
index eb6320c..5fe7260 100644
--- a/src/JobQueue.cpp
+++ b/src/JobQueue.cpp
@@ -128,5 +128,8 @@ void WorkerThread::doJob()
default:
break;
}
+ m_pQueue->Report(Job::eID_THREAD_JOB_DONE,
+ wxString::Format(wxT("Job #%d: finished."),
+ job.m_Arg.jobid), m_ID);
m_pQueue->decBusyWorker();
}
diff --git a/src/JobQueue.hpp b/src/JobQueue.hpp
index 46be586..116bc9f 100644
--- a/src/JobQueue.hpp
+++ b/src/JobQueue.hpp
@@ -53,6 +53,8 @@ public:
eID_THREAD_STARTED,
/* process normal job */
eID_THREAD_JOB,
+ /* job completed */
+ eID_THREAD_JOB_DONE,
/* process different messages in the frontend */
eID_THREAD_MSG,
eID_THREAD_MSGOK,
diff --git a/src/UpdateGUI.cpp b/src/UpdateGUI.cpp
index 9db59f9..f2fe3a5 100644
--- a/src/UpdateGUI.cpp
+++ b/src/UpdateGUI.cpp
@@ -120,7 +120,7 @@ UpdateGUIFrame::UpdateGUIFrame(const wxString& title, const wxPoint& pos, const
Centre();
jobs = new Queue(this);
{
- for (int tid = 1; tid <= 2; ++tid) {
+ for (int tid = 1; tid <= 3; ++tid) {
threads.push_back(tid);
WorkerThread* thread = new WorkerThread(jobs, tid);
if (thread) thread->Run();
@@ -325,6 +325,7 @@ void UpdateGUIFrame::OnThread(wxCommandEvent& event)
wxString wxs;
LogType tp = RTL_DEFAULT;
static size_t counter = 0;
+ bool printAllJobsDone = false;
/* some periodic informational output */
if ((++counter % 30) == 0) {
@@ -335,12 +336,25 @@ void UpdateGUIFrame::OnThread(wxCommandEvent& event)
/* process the wx event itself */
switch (event.GetId()) {
case Job::eID_THREAD_JOB:
+ case Job::eID_THREAD_JOB_DONE:
case Job::eID_THREAD_MSG:
case Job::eID_THREAD_MSGOK:
case Job::eID_THREAD_MSGERR:
wxs = wxString::Format(wxT("Thread [%i]: %s"), event.GetInt(), event.GetString().c_str());
switch (event.GetId()) {
+ case Job::eID_THREAD_JOB_DONE:
+ /* If more then one job was in the queue
+ * inform the user about job completion.
+ */
+ if (jobs->Stacksize() == 0 && jobs->getBusyWorker() == 0) {
+ if (jobs->getTotalJobsDone() > 1) {
+ counter = 0;
+ printAllJobsDone = true;
+ }
+ jobs->resetTotalJobsDone();
+ } else SetStatusText(wxs);
+ break;
case Job::eID_THREAD_JOB: SetStatusText(wxs); break;
case Job::eID_THREAD_MSGOK: SetStatusText(wxs); tp = RTL_GREEN; break;
case Job::eID_THREAD_MSGERR: tp = RTL_RED; break;
@@ -358,10 +372,8 @@ void UpdateGUIFrame::OnThread(wxCommandEvent& event)
default: event.Skip();
}
- /* give the user feedback if all jobs finished */
- if (jobs->getTotalJobsDone() > 1 && jobs->Stacksize() == 0 && jobs->getBusyWorker() == 0) {
+ if (printAllJobsDone) {
+ SetStatusText(wxT("All jobs finished."));
tLog(RTL_GREEN, "All jobs finished.");
- jobs->resetTotalJobsDone();
- counter = 0;
}
}