27 : fItemsPopped(0), fInputSize(0), fName(std::move(name)), fRunning(true), fPaused(true)
40 if(elem.second->IsRunning()) {
50 if(elem.second->IsRunning()) {
51 std::ostringstream status;
52 status << elem.first <<
":\t " << elem.second->Status();
61 std::ostringstream progress;
63 if(elem.second->IsRunning()) {
64 progress << std::left << std::setw(static_cast<int>(
fColumnWidth - 1)) << elem.second->Progress().substr(0,
fColumnWidth - 1) <<
"|";
66 std::string prog =
"not running";
75 std::ostringstream str;
85 std::ostringstream str;
87 if(elem.second->IsRunning()) {
88 str << std::left << std::setw(static_cast<int>(
fColumnWidth - 1)) << elem.second->Status().substr(0,
fColumnWidth - 1) <<
"|";
90 std::string prog =
"not running";
100 elem.second->Pause();
107 elem.second->Resume();
113 std::ostringstream str;
121 std::ostringstream str;
122 float percentDone = 100.f *
static_cast<float>(
fItemsPopped);
125 while(percentDone > 100.f /
static_cast<float>(
fColumnWidth - 1)) {
127 percentDone -= 100.f /
static_cast<float>(
fColumnWidth - 1);
130 str <<
"N/A: " << percentDone;
138 auto* data_loop =
dynamic_cast<TDataLoop*
>(elem.second);
140 if(data_loop !=
nullptr || chain_loop !=
nullptr) {
141 std::cout <<
"Stopping thread " << elem.first << std::endl;
152 std::cout <<
"Joining thread " << elem.first << std::endl;
159 std::cout <<
"Deleting thread " <<
fThreadMap.begin()->first << std::endl;
169 elem.second->ClearQueue();
213 std::cout << std::endl;
242 fPausedWait.wait_for(lock, std::chrono::milliseconds(100));
247 std::cout << std::endl;
257 std::cout <<
GetNThreads() <<
" Threads:" << std::endl;
260 std::cout <<
" " << counter <<
"\t" << thr.first <<
" @ " <<
hex(thr.second, 8) << std::endl;
289 std::this_thread::sleep_for(std::chrono::seconds(2));
292 std::ofstream outfile(Form(
"%s/.grsi_thread", getenv(
"GRSISYS")));
293 outfile <<
"---------------------------------------------------------------\n";
294 outfile <<
"---------------------------------------------------------------\n";
300 std::ofstream outfile(Form(
"%s/.grsi_thread", getenv(
"GRSISYS")));
301 outfile <<
"---------------------------------------------------------------\n";
304 outfile <<
"- " << thread->
Name() << (thread->
IsRunning() ?
"[Live]" :
"[Stop]")
305 << std::string(64 - 8 - thread->
Name().length(),
' ') <<
"-\n";
306 outfile <<
"- " << std::string(40,
' ') <<
"items_pushed: " << thread->
GetItemsPushed() <<
"\n";
307 outfile <<
"- " << std::string(40,
' ') <<
"items_popped: " << thread->
GetItemsPopped() <<
"\n";
308 outfile <<
"- " << std::string(40,
' ') <<
"items_current: " << thread->
GetItemsCurrent() <<
"\n";
309 outfile <<
"- " << std::string(40,
' ') <<
"rate: " << thread->
GetRate() <<
"\n";
310 outfile <<
"---------------------------------------------------------------\n";
312 outfile <<
"---------------------------------------------------------------\n";
317 std::vector<StoppableThread*> output(
fThreadMap.size(),
nullptr);
320 output[index++] = elem.second;
std::string hex(T val, int width=-1)
virtual std::string Status()
virtual size_t GetRate()=0
static void start_status_thread()
static std::string AnyThreadStatus()
StoppableThread(std::string name)
static void ClearAllQueues()
virtual std::string EndStatus()
virtual size_t GetItemsPushed()=0
static std::vector< StoppableThread * > GetAll()
static std::map< std::string, StoppableThread * > fThreadMap
static void join_status_thread()
static std::string AllThreadStatus()
static size_t fColumnWidth
static bool fStatusThreadOn
static void status_out_loop()
virtual std::string Progress()
static size_t fStatusWidth
virtual ~StoppableThread()
std::condition_variable fPausedWait
static std::string AllThreadProgress()
virtual size_t GetItemsPopped()=0
static std::string AllThreadHeader()
static StoppableThread * Get(const std::string &name)
static std::thread fStatusThread
static void stop_status_thread()
std::atomic_size_t fItemsPopped
number of items popped from input queue
static bool AnyThreadRunning()
std::atomic_long fInputSize
std::atomic_bool fRunning
virtual size_t GetItemsCurrent()=0
virtual bool Iteration()=0