git-svn-id: svn://db.shs.com.ru/pip@807 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-06-23 13:39:55 +00:00
parent 8a2a9e1684
commit 6da4f268d2
6 changed files with 43 additions and 20 deletions

View File

@@ -21,9 +21,10 @@
PIIntrospectionThreads::ThreadInfo::ThreadInfo() {
id = 0;
id = delay = 0;
state = sStopped;
priority = 0;
run_us = run_count = 0U;
}
@@ -34,59 +35,66 @@ PIIntrospectionThreads::PIIntrospectionThreads() {
void PIIntrospectionThreads::threadNew(PIThread * t) {
mutex.lock();
PIMutexLocker _ml(mutex);
ThreadInfo & ti(threads[t]);
ti.id = t->tid();
ti.priority = t->priority();
ti.name = t->name();
//piCout << "register thread" << id << name;
mutex.unlock();
}
void PIIntrospectionThreads::threadDelete(PIThread * t) {
mutex.lock();
PIMutexLocker _ml(mutex);
threads.remove(t);
mutex.unlock();
}
void PIIntrospectionThreads::threadStart(PIThread * t) {
PIMutexLocker _ml(mutex);
ThreadInfo & ti(threads[t]);
ti.id = t->tid();
ti.priority = t->priority();
ti.delay = t->delay_;
ti.state = sStarting;
}
void PIIntrospectionThreads::threadRun(PIThread * t) {
PIMutexLocker _ml(mutex);
ThreadInfo & ti(threads[t]);
ti.state = sRunning;
ti.run_count++;
}
void PIIntrospectionThreads::threadWait(PIThread * t) {
PIMutexLocker _ml(mutex);
threads[t].state = sWaiting;
}
void PIIntrospectionThreads::threadStop(PIThread * t) {
PIMutexLocker _ml(mutex);
threads[t].state = sStopped;
}
void PIIntrospectionThreads::threadRunDone(PIThread * t, ullong us) {
PIMutexLocker _ml(mutex);
ThreadInfo & ti(threads[t]);
ti.run_us = (ti.run_us * 0.8) + (us * 0.2); /// WARNING
}
PIByteArray & operator <<(PIByteArray & b, const PIIntrospectionThreads::ThreadInfo & v) {
b << v.name << v.id << int(v.state) << v.priority;
b << v.classname << v.name << v.id << int(v.state) << v.priority << v.delay << v.run_us << v.run_count;
return b;
}
PIByteArray & operator >>(PIByteArray & b, PIIntrospectionThreads::ThreadInfo & v) {
int st(0);
b >> v.id >> v.priority >> st >> v.name;
b >> v.classname >> v.name >> v.id >> st >> v.priority >> v.delay >> v.run_us >> v.run_count;
v.state = (PIIntrospectionThreads::ThreadState)st;
return b;
}