git-svn-id: svn://db.shs.com.ru/pip@819 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef PIP_INTROSPECTION
|
||||
|
||||
#include "piintrospection_server_p.h"
|
||||
#include "pichunkstream.h"
|
||||
#include "piinit.h"
|
||||
@@ -88,9 +86,9 @@ PIVector<PIIntrospection::ObjectInfo> PIIntrospection::getObjects() {
|
||||
}
|
||||
|
||||
|
||||
PIByteArray & operator <<(PIByteArray & s, const std::unordered_map<uint, PIIntrospectionContainers::Type> & v) {
|
||||
PIByteArray & operator <<(PIByteArray & s, const std::map<uint, PIIntrospectionContainers::Type> & v) {
|
||||
PIMap<uint, PIIntrospectionContainers::Type> m;
|
||||
for (typename std::unordered_map<uint, PIIntrospectionContainers::Type>::const_iterator i = v.cbegin(); i != v.cend(); ++i) {
|
||||
for (typename std::map<uint, PIIntrospectionContainers::Type>::const_iterator i = v.cbegin(); i != v.cend(); ++i) {
|
||||
m[i->first] = i->second;
|
||||
}
|
||||
s << m;
|
||||
@@ -188,13 +186,37 @@ void PIIntrospection::unpackInfo(PIByteArray & ba, PIIntrospection::ProcessInfo
|
||||
}
|
||||
|
||||
|
||||
PIByteArray PIIntrospection::packProcStat(PISystemMonitor * sm) {
|
||||
ProcessStat ps;
|
||||
if (sm) {
|
||||
ps.proc = sm->statistic();
|
||||
ps.threads = sm->threadsStatistic();
|
||||
}
|
||||
PIByteArray ret;
|
||||
ret << ps.proc << ps.threads;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void PIIntrospection::unpackProcStat(PIByteArray & ba, PIIntrospection::ProcessStat & info) {
|
||||
ba >> info.proc >> info.threads;
|
||||
}
|
||||
|
||||
|
||||
PIByteArray PIIntrospection::packContainers() {
|
||||
PIByteArray ret;
|
||||
PIIntrospectionContainers * p = PIINTROSPECTION_CONTAINERS->p;
|
||||
p->mutex.lock();
|
||||
std::unordered_map<uint, PIIntrospectionContainers::Type> data = p->data;
|
||||
std::unordered_map<uint, std::string> typenames = p->typenames;
|
||||
p->mutex.unlock();
|
||||
std::map<uint, PIIntrospectionContainers::Type> data;
|
||||
std::map<uint, std::string> typenames;
|
||||
PIIntrospectionContainers * p = 0;
|
||||
#ifdef PIP_INTROSPECTION
|
||||
p = PIINTROSPECTION_CONTAINERS->p;
|
||||
#endif
|
||||
if (p) {
|
||||
p->mutex.lock();
|
||||
data = p->data;
|
||||
typenames = p->typenames;
|
||||
p->mutex.unlock();
|
||||
}
|
||||
ret << data << typenames;
|
||||
return ret;
|
||||
}
|
||||
@@ -209,15 +231,22 @@ void PIIntrospection::unpackContainers(PIByteArray & ba, PIMap<uint, PIIntrospec
|
||||
|
||||
PIByteArray PIIntrospection::packThreads() {
|
||||
PIByteArray ret;
|
||||
PIIntrospectionThreads * p = PIINTROSPECTION_THREADS->p;
|
||||
p->mutex.lock();
|
||||
PIMap<PIThread*, PIIntrospectionThreads::ThreadInfo> & tm(p->threads);
|
||||
for (PIMap<PIThread*, PIIntrospectionThreads::ThreadInfo>::iterator i = tm.begin(); i != tm.end(); ++i) {
|
||||
i.value().classname = PIStringAscii(i.key()->className());
|
||||
i.value().name = i.key()->name();
|
||||
PIIntrospectionThreads * p = 0;
|
||||
#ifdef PIP_INTROSPECTION
|
||||
p = PIINTROSPECTION_THREADS->p;
|
||||
#endif
|
||||
if (p) {
|
||||
p->mutex.lock();
|
||||
PIMap<PIThread*, PIIntrospectionThreads::ThreadInfo> & tm(p->threads);
|
||||
for (PIMap<PIThread*, PIIntrospectionThreads::ThreadInfo>::iterator i = tm.begin(); i != tm.end(); ++i) {
|
||||
i.value().classname = PIStringAscii(i.key()->className());
|
||||
i.value().name = i.key()->name();
|
||||
}
|
||||
ret << tm.values();
|
||||
p->mutex.unlock();
|
||||
} else {
|
||||
ret << PIVector<PIIntrospectionThreads::ThreadInfo>();
|
||||
}
|
||||
ret << tm.values();
|
||||
p->mutex.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -239,5 +268,3 @@ void PIIntrospection::unpackObjects(PIByteArray & ba, PIVector<PIIntrospection::
|
||||
objects.clear();
|
||||
ba >> objects;
|
||||
}
|
||||
|
||||
#endif // PIP_INTROSPECTION
|
||||
|
||||
Reference in New Issue
Block a user