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
|
||||||
@@ -345,8 +346,8 @@ void PITerminal::getCursor(int & x, int & y) {
|
|||||||
int sz = 0;
|
int sz = 0;
|
||||||
PRIVATE->shm->read(&sz, 4);
|
PRIVATE->shm->read(&sz, 4);
|
||||||
# else
|
# else
|
||||||
x = PRIVATE->cur_x;
|
x = PRIVATE->cur_x;
|
||||||
y = PRIVATE->cur_y;
|
y = PRIVATE->cur_y;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,7 +934,7 @@ void PITerminal::destroy() {
|
|||||||
}
|
}
|
||||||
if (PRIVATE->pipe != INVALID_HANDLE_VALUE) CloseHandle(PRIVATE->pipe);
|
if (PRIVATE->pipe != INVALID_HANDLE_VALUE) CloseHandle(PRIVATE->pipe);
|
||||||
if (PRIVATE->hConBuf != INVALID_HANDLE_VALUE) CloseHandle(PRIVATE->hConBuf);
|
if (PRIVATE->hConBuf != INVALID_HANDLE_VALUE) CloseHandle(PRIVATE->hConBuf);
|
||||||
// piCout << "destroy" << size_y;
|
// piCout << "destroy" << size_y;
|
||||||
# else
|
# else
|
||||||
# ifdef HAS_FORKPTY
|
# ifdef HAS_FORKPTY
|
||||||
if (PRIVATE->pid != 0) kill(PRIVATE->pid, SIGKILL);
|
if (PRIVATE->pid != 0) kill(PRIVATE->pid, SIGKILL);
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -517,10 +518,10 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
|||||||
_stat_struct_ fs;
|
_stat_struct_ fs;
|
||||||
piZeroMemory(fs);
|
piZeroMemory(fs);
|
||||||
_stat_call_(path.data(), &fs);
|
_stat_call_(path.data(), &fs);
|
||||||
int mode = fs.st_mode;
|
int mode = fs.st_mode;
|
||||||
ret.size = fs.st_size;
|
ret.size = fs.st_size;
|
||||||
ret.id_user = fs.st_uid;
|
ret.id_user = fs.st_uid;
|
||||||
ret.id_group = fs.st_gid;
|
ret.id_group = fs.st_gid;
|
||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.st_atime, fs.st_atime_nsec));
|
ret.time_access = PIDateTime::fromSystemTime(PISystemTime(fs.st_atime, fs.st_atime_nsec));
|
||||||
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.st_mtime, fs.st_mtime_nsec));
|
ret.time_modification = PIDateTime::fromSystemTime(PISystemTime(fs.st_mtime, fs.st_mtime_nsec));
|
||||||
@@ -541,9 +542,9 @@ PIFile::FileInfo PIFile::fileInfo(const PIString & path) {
|
|||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# ifndef MICRO_PIP
|
# ifndef MICRO_PIP
|
||||||
ret.perm_user = FileInfo::Permissions((mode & S_IRUSR) == S_IRUSR, (mode & S_IWUSR) == S_IWUSR, (mode & S_IXUSR) == S_IXUSR);
|
ret.perm_user = FileInfo::Permissions((mode & S_IRUSR) == S_IRUSR, (mode & S_IWUSR) == S_IWUSR, (mode & S_IXUSR) == S_IXUSR);
|
||||||
ret.perm_group = FileInfo::Permissions((mode & S_IRGRP) == S_IRGRP, (mode & S_IWGRP) == S_IWGRP, (mode & S_IXGRP) == S_IXGRP);
|
ret.perm_group = FileInfo::Permissions((mode & S_IRGRP) == S_IRGRP, (mode & S_IWGRP) == S_IWGRP, (mode & S_IXGRP) == S_IXGRP);
|
||||||
ret.perm_other = FileInfo::Permissions((mode & S_IROTH) == S_IROTH, (mode & S_IWOTH) == S_IWOTH, (mode & S_IXOTH) == S_IXOTH);
|
ret.perm_other = FileInfo::Permissions((mode & S_IROTH) == S_IROTH, (mode & S_IWOTH) == S_IWOTH, (mode & S_IXOTH) == S_IXOTH);
|
||||||
piZeroMemory(fs);
|
piZeroMemory(fs);
|
||||||
_stat_link_(path.data(), &fs);
|
_stat_link_(path.data(), &fs);
|
||||||
mode &= ~S_IFLNK;
|
mode &= ~S_IFLNK;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void setCommands() {
|
|||||||
cmd_copydir = "cp -rf ";
|
cmd_copydir = "cp -rf ";
|
||||||
ign_err_suffix = " 2> /dev/null";
|
ign_err_suffix = " 2> /dev/null";
|
||||||
# ifdef MAC_OS
|
# ifdef MAC_OS
|
||||||
qplatforms = "cocoa";
|
qplatforms = "cocoa";
|
||||||
# else
|
# else
|
||||||
qplatforms = "xcb,wayland";
|
qplatforms = "xcb,wayland";
|
||||||
# endif
|
# endif
|
||||||
@@ -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