- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread.cpp
More file actions
Latest commit
34 lines (34 loc) · 1020 Bytes
/
Copy paththread.cpp
File metadata and controls
34 lines (34 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include"thread.h"
#include"stdarg.h"
extern"C"{
externvolatilebool g_halted;
voidcalc();
voidemit_warning(constchar*str){emit calculation.warning(str);}
voidemit_output(constchar*str){emit calculation.output(str);}
voidemit_maximum(int max){emit calculation.maximum(max);}
voidemit_progress(int prg){emit calculation.progress(prg);}
voidemit_completed1st(){emit calculation.completed1st();}
void*emit_error(constchar*str,...){//accepts a null-terminated list of strings to output
QString string = "";
va_list v;
va_start(v,str);
while(str){
string += str;
str = va_arg(v,constchar*);
}
va_end(v);
bool calc = QThread::currentThread() == calculation.currentThread();
if(calc) string += "<br>Halting Calculation";
emit calculation.error(string);//connected to handling slot in window.cpp
if(calc) calculation.sleep(~0UL);
return0;
}}
voidThread::begin(){
if(!isRunning()){
emit starting();
start();
}
}
voidThread::run(){calc();}
voidThread::stop(){g_halted=true;}
Thread calculation;