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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#include "array.hpp"
#include "statushandler.hpp"
namespace ngcore
{
volatile multithreadt multithread;
multithreadt :: multithreadt()
{
pause =0;
testmode = 0;
redraw = 0;
drawing = 0;
terminate = 0;
running = 0;
percent = 0;
task = "";
}
static Array<std::string> msgstatus_stack(0);
static Array<double> threadpercent_stack(0);
static std::string msgstatus = "";
void ResetStatus()
{
SetStatMsg("idle");
// for (int i = 0; i < msgstatus_stack.Size(); i++)
// delete msgstatus_stack[i];
msgstatus_stack.SetSize(0);
threadpercent_stack.SetSize(0);
// multithread.task = "";
multithread.percent = 100.;
}
void PushStatus(const std::string& s)
{
msgstatus_stack.Append(s);
SetStatMsg(s);
threadpercent_stack.Append(0);
}
void PopStatus()
{
if (msgstatus_stack.Size())
{
if (msgstatus_stack.Size() > 1)
// SetStatMsg (*msgstatus_stack.Last());
SetStatMsg (msgstatus_stack[msgstatus_stack.Size()-2]);
else
SetStatMsg ("");
// delete msgstatus_stack.Last();
msgstatus_stack.DeleteLast();
threadpercent_stack.DeleteLast();
if(threadpercent_stack.Size() > 0)
multithread.percent = threadpercent_stack.Last();
else
multithread.percent = 100.;
}
else
{
// PrintSysError("PopStatus failed");
;
}
}
/*
void SetStatMsgF(const MyStr& s)
{
PrintFnStart(s);
SetStatMsg(s);
}
*/
void SetStatMsg(const std::string& s)
{
msgstatus = s;
multithread.task = msgstatus.c_str();
}
void SetThreadPercent(double percent)
{
multithread.percent = percent;
if(threadpercent_stack.Size() > 0)
threadpercent_stack.Last() = percent;
}
void GetStatus(std::string & s, double & percentage)
{
if(threadpercent_stack.Size() > 0)
percentage = threadpercent_stack.Last();
else
percentage = multithread.percent;
if ( msgstatus_stack.Size() )
s = msgstatus_stack.Last();
else
s = "idle";
}
}
|