remove some ifdefs
This commit is contained in:
@@ -114,7 +114,7 @@ bool PISystemMonitor::startOnProcess(int pID, PISystemTime interval) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_);
|
PRIVATE->hProc = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pID_);
|
||||||
if (PRIVATE->hProc == 0) {
|
if (PRIVATE->hProc == 0) {
|
||||||
piCoutObj << "Can`t open process with ID = %1, %2!"_tr("PISystemMonitor").arg(pID_).arg(errorString());
|
piCoutObj << "Can`t open process with ID = %1, %2!"_tr("PISystemMonitor").arg(pID_).arg(errorString());
|
||||||
return false;
|
return false;
|
||||||
@@ -180,8 +180,7 @@ void PISystemMonitor::run() {
|
|||||||
cur_tm.clear();
|
cur_tm.clear();
|
||||||
tbid.clear();
|
tbid.clear();
|
||||||
ProcessStats tstat;
|
ProcessStats tstat;
|
||||||
tstat.ID = pID_;
|
tstat.ID = pID_;
|
||||||
# ifdef PIP_HAS_THREADS
|
|
||||||
__PIThreadCollection * pitc = __PIThreadCollection::instance();
|
__PIThreadCollection * pitc = __PIThreadCollection::instance();
|
||||||
pitc->lock();
|
pitc->lock();
|
||||||
PIVector<PIThread *> tv = pitc->threads();
|
PIVector<PIThread *> tv = pitc->threads();
|
||||||
@@ -189,14 +188,14 @@ void PISystemMonitor::run() {
|
|||||||
if (t->isPIObject()) tbid[t->tid()] = t->name();
|
if (t->isPIObject()) tbid[t->tid()] = t->name();
|
||||||
pitc->unlock();
|
pitc->unlock();
|
||||||
// piCout << tbid.keys().toType<uint>();
|
// piCout << tbid.keys().toType<uint>();
|
||||||
# ifdef FREERTOS
|
# ifdef FREERTOS
|
||||||
for (auto * t: tv)
|
for (auto * t: tv)
|
||||||
if (t->isPIObject()) gatherThread(t->tid());
|
if (t->isPIObject()) gatherThread(t->tid());
|
||||||
# else // FREERTOS
|
# else // FREERTOS
|
||||||
# ifndef WINDOWS
|
# ifndef WINDOWS
|
||||||
double delay_ms = delay_.toMilliseconds();
|
double delay_ms = delay_.toMilliseconds();
|
||||||
tbid[pID_] = "main";
|
tbid[pID_] = "main";
|
||||||
# ifdef MAC_OS
|
# ifdef MAC_OS
|
||||||
rusage_info_current ru;
|
rusage_info_current ru;
|
||||||
proc_pid_rusage(pID_, RUSAGE_INFO_CURRENT, (rusage_info_t *)&ru);
|
proc_pid_rusage(pID_, RUSAGE_INFO_CURRENT, (rusage_info_t *)&ru);
|
||||||
// piCout << PISystemTime(((uint*)&(ru.ri_user_time))[1], ((uint*)&(ru.ri_user_time))[0]);
|
// piCout << PISystemTime(((uint*)&(ru.ri_user_time))[1], ((uint*)&(ru.ri_user_time))[0]);
|
||||||
@@ -212,7 +211,7 @@ void PISystemMonitor::run() {
|
|||||||
tstat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
tstat.cpu_load_user = 100.f * (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
||||||
cycle = 0;
|
cycle = 0;
|
||||||
// piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
// piCout << (PRIVATE->cpu_u_cur - PRIVATE->cpu_u_prev).toMilliseconds() / delay_ms;
|
||||||
# else // MAC_OS
|
# else // MAC_OS
|
||||||
PRIVATE->file.seekToBegin();
|
PRIVATE->file.seekToBegin();
|
||||||
PIString str = PIString::fromAscii(PRIVATE->file.readAll());
|
PIString str = PIString::fromAscii(PRIVATE->file.readAll());
|
||||||
int si = str.find('(') + 1, fi = 0, cc = 1;
|
int si = str.find('(') + 1, fi = 0, cc = 1;
|
||||||
@@ -266,8 +265,8 @@ void PISystemMonitor::run() {
|
|||||||
if (i.flags[PIFile::FileInfo::Dot] || i.flags[PIFile::FileInfo::DotDot]) continue;
|
if (i.flags[PIFile::FileInfo::Dot] || i.flags[PIFile::FileInfo::DotDot]) continue;
|
||||||
gatherThread(i.name().toInt());
|
gatherThread(i.name().toInt());
|
||||||
}
|
}
|
||||||
# endif // MAC_OS
|
# endif // MAC_OS
|
||||||
# else // WINDOWS
|
# else // WINDOWS
|
||||||
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
if (GetProcessMemoryInfo(PRIVATE->hProc, &PRIVATE->mem_cnt, sizeof(PRIVATE->mem_cnt)) != 0) {
|
||||||
tstat.physical_memsize = PRIVATE->mem_cnt.WorkingSetSize;
|
tstat.physical_memsize = PRIVATE->mem_cnt.WorkingSetSize;
|
||||||
}
|
}
|
||||||
@@ -317,9 +316,8 @@ void PISystemMonitor::run() {
|
|||||||
tstat.cpu_load_user = 0.f;
|
tstat.cpu_load_user = 0.f;
|
||||||
}
|
}
|
||||||
PRIVATE->tm.reset();
|
PRIVATE->tm.reset();
|
||||||
# endif // WINDOWS
|
# endif // WINDOWS
|
||||||
# endif // FREERTOS
|
# endif // FREERTOS
|
||||||
# endif // PIP_HAS_THREADS
|
|
||||||
|
|
||||||
tstat.cpu_load_system = piClampf(tstat.cpu_load_system, 0.f, 100.f);
|
tstat.cpu_load_system = piClampf(tstat.cpu_load_system, 0.f, 100.f);
|
||||||
tstat.cpu_load_user = piClampf(tstat.cpu_load_user, 0.f, 100.f);
|
tstat.cpu_load_user = piClampf(tstat.cpu_load_user, 0.f, 100.f);
|
||||||
@@ -355,7 +353,7 @@ void PISystemMonitor::gatherThread(llong id) {
|
|||||||
# ifndef PIP_HAS_PROCESS
|
# ifndef PIP_HAS_PROCESS
|
||||||
ts.name = tbid.value(id, "<PIThread>");
|
ts.name = tbid.value(id, "<PIThread>");
|
||||||
# else
|
# else
|
||||||
ts.name = tbid.value(id, "<non-PIThread>");
|
ts.name = tbid.value(id, "<non-PIThread>");
|
||||||
# ifndef WINDOWS
|
# ifndef WINDOWS
|
||||||
PIFile f(PRIVATE->proc_dir + "task/" + PIString::fromNumber(id) + "/stat");
|
PIFile f(PRIVATE->proc_dir + "task/" + PIString::fromNumber(id) + "/stat");
|
||||||
// piCout << f.path();
|
// piCout << f.path();
|
||||||
|
|||||||
@@ -279,8 +279,6 @@ void PIBaseTransfer::received(PIByteArray data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef PIP_HAS_THREADS
|
|
||||||
#endif
|
|
||||||
case pt_Pause:
|
case pt_Pause:
|
||||||
mutex_header.lock();
|
mutex_header.lock();
|
||||||
if (header.session_id == h.session_id) {
|
if (header.session_id == h.session_id) {
|
||||||
|
|||||||
@@ -450,8 +450,6 @@ __THREAD_FUNC_RET__ thread_function_once(void * t) {
|
|||||||
//! \return \c false если таймаут истёк
|
//! \return \c false если таймаут истёк
|
||||||
|
|
||||||
|
|
||||||
# ifdef PIP_HAS_THREADS
|
|
||||||
|
|
||||||
__PIThreadCollection * __PIThreadCollection::instance() {
|
__PIThreadCollection * __PIThreadCollection::instance() {
|
||||||
return __PIThreadCollection_Initializer__::__instance__;
|
return __PIThreadCollection_Initializer__::__instance__;
|
||||||
}
|
}
|
||||||
@@ -516,8 +514,6 @@ __PIThreadCollection_Initializer__::~__PIThreadCollection_Initializer__() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif // PIP_HAS_THREADS
|
|
||||||
|
|
||||||
|
|
||||||
PRIVATE_DEFINITION_START(PIThread)
|
PRIVATE_DEFINITION_START(PIThread)
|
||||||
# if defined(WINDOWS)
|
# if defined(WINDOWS)
|
||||||
@@ -1003,10 +999,8 @@ void PIThread::runOnce(PIObject * object, const char * handler, const PIString &
|
|||||||
delete t;
|
delete t;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# ifdef PIP_HAS_THREADS
|
|
||||||
__PIThreadCollection::instance()->startedAuto(t);
|
__PIThreadCollection::instance()->startedAuto(t);
|
||||||
CONNECT0(void, t, stopped, __PIThreadCollection::instance(), stoppedAuto);
|
CONNECT0(void, t, stopped, __PIThreadCollection::instance(), stoppedAuto);
|
||||||
# endif
|
|
||||||
t->startOnce();
|
t->startOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1037,10 +1031,8 @@ void PIThread::runOnce(std::function<void()> func, const PIString & name) {
|
|||||||
PIThread * t = new PIThread();
|
PIThread * t = new PIThread();
|
||||||
t->setName(name);
|
t->setName(name);
|
||||||
t->setSlot(std::move(func));
|
t->setSlot(std::move(func));
|
||||||
# ifdef PIP_HAS_THREADS
|
|
||||||
__PIThreadCollection::instance()->startedAuto(t);
|
__PIThreadCollection::instance()->startedAuto(t);
|
||||||
CONNECT0(void, t, stopped, __PIThreadCollection::instance(), stoppedAuto);
|
CONNECT0(void, t, stopped, __PIThreadCollection::instance(), stoppedAuto);
|
||||||
# endif
|
|
||||||
t->startOnce();
|
t->startOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,9 +97,7 @@ typedef std::function<void(void *)> ThreadFunc;
|
|||||||
//! проход без повторяющегося цикла обработки очереди.
|
//! проход без повторяющегося цикла обработки очереди.
|
||||||
class PIP_EXPORT PIThread: public PIObject {
|
class PIP_EXPORT PIThread: public PIObject {
|
||||||
PIOBJECT_SUBCLASS(PIThread, PIObject);
|
PIOBJECT_SUBCLASS(PIThread, PIObject);
|
||||||
# ifdef PIP_HAS_THREADS
|
|
||||||
friend class PIIntrospectionThreads;
|
friend class PIIntrospectionThreads;
|
||||||
# endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NO_COPY_CLASS(PIThread);
|
NO_COPY_CLASS(PIThread);
|
||||||
|
|||||||
Reference in New Issue
Block a user