PITimeMeasurer remove some API, add elapsedAndReset()
got rid off some warnings
This commit is contained in:
@@ -147,7 +147,8 @@ void PITerminal::write(const PIByteArray & d) {
|
|||||||
if (PRIVATE->fd == 0) return;
|
if (PRIVATE->fd == 0) return;
|
||||||
// ssize_t wrote = 0;
|
// ssize_t wrote = 0;
|
||||||
// wrote =
|
// wrote =
|
||||||
::write(PRIVATE->fd, d.data(), d.size_s());
|
auto _r = ::write(PRIVATE->fd, d.data(), d.size_s());
|
||||||
|
NO_UNUSED(_r);
|
||||||
// piCout << "wrote" << wrote << d;
|
// piCout << "wrote" << wrote << d;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ void PIWaitEvent::interrupt() {
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
SetEvent(event);
|
SetEvent(event);
|
||||||
#else
|
#else
|
||||||
::write(pipe_fd[WriteEnd], "", 1);
|
auto _r = ::write(pipe_fd[WriteEnd], "", 1);
|
||||||
|
NO_UNUSED(_r);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -263,7 +263,8 @@ PIByteArray PIFile::readAll(bool forceRead) {
|
|||||||
if (s < 0) return a;
|
if (s < 0) return a;
|
||||||
a.resize(s);
|
a.resize(s);
|
||||||
seekToBegin();
|
seekToBegin();
|
||||||
fread(a.data(), 1, s, PRIVATE->fd);
|
auto _r = fread(a.data(), 1, s, PRIVATE->fd);
|
||||||
|
NO_UNUSED(_r);
|
||||||
seek(cp);
|
seek(cp);
|
||||||
if (s >= 0) a.resize(s);
|
if (s >= 0) a.resize(s);
|
||||||
return a;
|
return a;
|
||||||
|
|||||||
@@ -136,7 +136,10 @@ bool PISharedMemory::openDevice() {
|
|||||||
PRIVATE->owner = true;
|
PRIVATE->owner = true;
|
||||||
// piCoutObj << "created" << fd;
|
// piCoutObj << "created" << fd;
|
||||||
}
|
}
|
||||||
if (fd >= 0) ftruncate(fd, dsize);
|
if (fd >= 0) {
|
||||||
|
auto _r = ftruncate(fd, dsize);
|
||||||
|
NO_UNUSED(_r);
|
||||||
|
}
|
||||||
PRIVATE->data = mmap(0, dsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
PRIVATE->data = mmap(0, dsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
::close(fd);
|
::close(fd);
|
||||||
if (PRIVATE->data == MAP_FAILED) {
|
if (PRIVATE->data == MAP_FAILED) {
|
||||||
|
|||||||
@@ -833,11 +833,11 @@ bool PIThread::waitForFinish(PISystemTime timeout) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
tmf_.reset();
|
PITimeMeasurer tm;
|
||||||
while (tmf_.elapsed() < timeout) {
|
while (tm.elapsed() < timeout) {
|
||||||
if (_waitForFinish(PISystemTime::fromMilliseconds(PIP_MIN_MSLEEP))) return true;
|
if (_waitForFinish(PISystemTime::fromMilliseconds(PIP_MIN_MSLEEP))) return true;
|
||||||
}
|
}
|
||||||
return tmf_.elapsed() < timeout;
|
return tm.elapsed() < timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -848,10 +848,10 @@ bool PIThread::waitForStart(PISystemTime timeout) {
|
|||||||
piMinSleep();
|
piMinSleep();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
tms_.reset();
|
PITimeMeasurer tm;
|
||||||
while (!running_ && tms_.elapsed() < timeout)
|
while (!running_ && tm.elapsed() < timeout)
|
||||||
piMinSleep();
|
piMinSleep();
|
||||||
return tms_.elapsed() < timeout;
|
return tm.elapsed() < timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -950,10 +950,10 @@ void PIThread::__thread_func__() {
|
|||||||
// PICout(PICoutManipulators::DefaultControls) << "thread" << this << "wait" << "...";
|
// PICout(PICoutManipulators::DefaultControls) << "thread" << this << "wait" << "...";
|
||||||
PIINTROSPECTION_THREAD_WAIT(this);
|
PIINTROSPECTION_THREAD_WAIT(this);
|
||||||
if (delay_.isNotNull()) {
|
if (delay_.isNotNull()) {
|
||||||
tmr_.reset();
|
PITimeMeasurer tm;
|
||||||
double sl(0.);
|
double sl(0.);
|
||||||
while (1) {
|
while (1) {
|
||||||
sl = piMind(delay_.toMilliseconds() - tmr_.elapsed_m(), PIP_MIN_MSLEEP);
|
sl = piMind(delay_.toMilliseconds() - tm.elapsed_m(), PIP_MIN_MSLEEP);
|
||||||
if (terminating) break;
|
if (terminating) break;
|
||||||
if (sl <= 0.) break;
|
if (sl <= 0.) break;
|
||||||
piMSleep(sl);
|
piMSleep(sl);
|
||||||
|
|||||||
@@ -288,7 +288,6 @@ protected:
|
|||||||
llong tid_ = -1;
|
llong tid_ = -1;
|
||||||
void * data_ = nullptr;
|
void * data_ = nullptr;
|
||||||
mutable PIMutex thread_mutex;
|
mutable PIMutex thread_mutex;
|
||||||
PITimeMeasurer tmf_, tms_, tmr_;
|
|
||||||
PIThread::Priority priority_ = piNormal;
|
PIThread::Priority priority_ = piNormal;
|
||||||
ThreadFunc ret_func = nullptr;
|
ThreadFunc ret_func = nullptr;
|
||||||
PIThreadNotifier state_notifier;
|
PIThreadNotifier state_notifier;
|
||||||
|
|||||||
@@ -317,6 +317,14 @@ PISystemTime PITimeMeasurer::elapsed() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PISystemTime PITimeMeasurer::elapsedAndReset() {
|
||||||
|
auto ct = PISystemTime::current(true);
|
||||||
|
auto ret = ct - t_st;
|
||||||
|
t_st = ct;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// PISystemTime::Frequency
|
// PISystemTime::Frequency
|
||||||
|
|
||||||
PISystemTime PISystemTime::Frequency::toSystemTime() const {
|
PISystemTime PISystemTime::Frequency::toSystemTime() const {
|
||||||
|
|||||||
@@ -501,43 +501,24 @@ public:
|
|||||||
//! \~russian Возвращает в PISystemTime время, прошедшее с последнего вызова \a reset(), либо создания измерителя.
|
//! \~russian Возвращает в PISystemTime время, прошедшее с последнего вызова \a reset(), либо создания измерителя.
|
||||||
PISystemTime elapsed() const;
|
PISystemTime elapsed() const;
|
||||||
|
|
||||||
double reset_time_n() const { return t_st.toNanoseconds(); }
|
//! \~\brief
|
||||||
double reset_time_u() const { return t_st.toMicroseconds(); }
|
//! \~english Returns PISystemTime elapsed from last \a reset() execution or from timer measurer creation and call \a reset().
|
||||||
double reset_time_m() const { return t_st.toMilliseconds(); }
|
//! \~russian Возвращает в PISystemTime время, прошедшее с последнего вызова \a reset(), либо создания измерителя, и вызывает \a
|
||||||
double reset_time_s() const { return t_st.toSeconds(); }
|
//! reset().
|
||||||
|
PISystemTime elapsedAndReset();
|
||||||
|
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Returns time mark of last \a reset() execution or timer measurer creation.
|
//! \~english Returns time mark of last \a reset() execution or timer measurer creation.
|
||||||
//! \~russian Возвращает отметку времени последнего вызова \a reset(), либо создания измерителя.
|
//! \~russian Возвращает отметку времени последнего вызова \a reset(), либо создания измерителя.
|
||||||
PISystemTime reset_time() { return t_st; }
|
PISystemTime reset_time() DEPRECATEDM("use PISystemTime::resetTime()") { return t_st; }
|
||||||
|
|
||||||
//! \~\brief
|
//! \~\brief
|
||||||
//! \~english Returns nanoseconds representation of current system time.
|
//! \~english Returns time mark of last \a reset() execution or timer measurer creation.
|
||||||
//! \~russian Возвращает в наносекундах системное время.
|
//! \~russian Возвращает отметку времени последнего вызова \a reset(), либо создания измерителя.
|
||||||
static double elapsed_system_n() { return PISystemTime::current(true).toNanoseconds(); }
|
PISystemTime resetTime() const { return t_st; }
|
||||||
|
|
||||||
//! \~\brief
|
|
||||||
//! \~english Returns microseconds representation of current system time.
|
|
||||||
//! \~russian Возвращает в микросекундах системное время.
|
|
||||||
static double elapsed_system_u() { return PISystemTime::current(true).toMicroseconds(); }
|
|
||||||
|
|
||||||
//! \~\brief
|
|
||||||
//! \~english Returns milliseconds representation of current system time.
|
|
||||||
//! \~russian Возвращает в милисекундах системное время.
|
|
||||||
static double elapsed_system_m() { return PISystemTime::current(true).toMilliseconds(); }
|
|
||||||
|
|
||||||
//! \~\brief
|
|
||||||
//! \~english Returns seconds representation of current system time.
|
|
||||||
//! \~russian Возвращает в секундах системное время.
|
|
||||||
static double elapsed_system_s() { return PISystemTime::current(true).toSeconds(); }
|
|
||||||
|
|
||||||
//! \~\brief
|
|
||||||
//! \~english Returns time mark of current system time.
|
|
||||||
//! \~russian Возвращает системное время.
|
|
||||||
static PISystemTime elapsed_system() { return PISystemTime::current(true); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PISystemTime t_st, t_cur;
|
PISystemTime t_st;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PITIME_H
|
#endif // PITIME_H
|
||||||
|
|||||||
@@ -381,7 +381,8 @@ void copyWildcard(const PIString & from, const PIString & to) {
|
|||||||
PIFile::FileInfo fi(from);
|
PIFile::FileInfo fi(from);
|
||||||
system(("robocopy \"" + fi.dir() + "\" \"" + to + "\" \"" + fi.name() + "\" /E /NJH /NJS /NP /NDL /NS /NC /NFL 1> NUL").data());
|
system(("robocopy \"" + fi.dir() + "\" \"" + to + "\" \"" + fi.name() + "\" /E /NJH /NJS /NP /NDL /NS /NC /NFL 1> NUL").data());
|
||||||
#else
|
#else
|
||||||
system((cmd_copy + from + " \"" + to + "/\"" + cmd_suffix).data());
|
auto _r = system((cmd_copy + from + " \"" + to + "/\"" + cmd_suffix).data());
|
||||||
|
NO_UNUSED(_r);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,13 +798,14 @@ int main(int argc, char * argv[]) {
|
|||||||
if (need_cp) {
|
if (need_cp) {
|
||||||
piCout << "copy" << l;
|
piCout << "copy" << l;
|
||||||
if (!fake) {
|
if (!fake) {
|
||||||
system((cmd_copy + "\"" + l + "\" \"" + out_dir + "\"" + cmd_suffix).data());
|
auto _r = system((cmd_copy + "\"" + l + "\" \"" + out_dir + "\"" + cmd_suffix).data());
|
||||||
if (strip.isNotEmpty()) {
|
if (strip.isNotEmpty()) {
|
||||||
if (!otool.isEmpty()) // Apple
|
if (!otool.isEmpty()) // Apple
|
||||||
system((strip + " -S \"" + out_dir + fi.name() + "\"").data());
|
_r = system((strip + " -S \"" + out_dir + fi.name() + "\"").data());
|
||||||
else
|
else
|
||||||
system((strip + " --strip-unneeded \"" + out_dir + fi.name() + "\"").data());
|
_r = system((strip + " --strip-unneeded \"" + out_dir + fi.name() + "\"").data());
|
||||||
}
|
}
|
||||||
|
NO_UNUSED(_r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -812,7 +814,10 @@ int main(int argc, char * argv[]) {
|
|||||||
PIString fd = findLib(f);
|
PIString fd = findLib(f);
|
||||||
if (!fd.isEmpty()) {
|
if (!fd.isEmpty()) {
|
||||||
piCout << "copy framework" << f;
|
piCout << "copy framework" << f;
|
||||||
if (!fake) system((cmd_copydir + "\"" + fd + "\" \"" + out_dir + "\"" + cmd_suffix).data());
|
if (!fake) {
|
||||||
|
auto _r = system((cmd_copydir + "\"" + fd + "\" \"" + out_dir + "\"" + cmd_suffix).data());
|
||||||
|
NO_UNUSED(_r);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
miss_frameworks << f;
|
miss_frameworks << f;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user