void Executor::executor_func(void * arg) { Executor *executor=(Executor*)arg; executor->mLog.msg("Thread executor id %llu is now alive and waiting ...\n",executor->id().value); TaskArray jobArray; while(executor->mIsRunningInternal.test_and_set()) { jobArray.clear(); executor->queue()->get(jobArray,1,true); if (!jobArray.empty()) { executor->mJobTimer.restart(); auto current = jobArray.begin(); while (current != jobArray.end()) { executor->mStats.jobsExecuted++; TaskResult::Result result=current->execute(executor->id(),InterruptPoint(&executor->mIsRunningExternal)); if(result==TaskResult::Skipped) executor->mStats.jobsSkipped++; else if (result==TaskResult::Success) executor->mStats.jobsSucesfullyExecuted++; ++current; } executor->mStats.busyMilliseconds+=executor->mJobTimer.elapsedTimeMilliseconds(); } } executor->mLog.msg("Thread executor %llu is terminating ...\n",executor->id().value); }
int all_tasks_to_string( char *buffer ) { if (NULL == buffer) { LOG_STRING("Passing NULL to all_tasks_to_string!!"); return -1; } if (tasklist.empty()) { LOG_STRING("Tasklist is empty!!"); return -2; } UString tmp = ""; char buf[1024]; TaskPtr p; int s = 0; TaskArray::iterator it = tasklist.begin(); tmp += "<Tasks>"; for(; it != tasklist.end(); ++it) { p= *it; s = (int)p->ts; sprintf(buf, "<task>" "<id>%d</id>" "<name>%s</name>" "<sid>%d</sid>" "<subdir>%s</subdir>" "<status>%s</status>" "</task>", p->id, p->name, p->sid, p->subdir, TaskStateText[s]); tmp += buf; } tmp += "</Tasks>"; sprintf(buffer, "%s", tmp.c_str()); return 0; }