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