//! \~\file pitime.h
//! \~\ingroup Types
//! \~\brief
//! \~english System time, time and date
//! \~russian Системное время, время и дата
/*
    PIP - Platform Independent Primitives
    Ivan Pelipenko peri4ko@yandex.ru

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef PITIME_H
#define PITIME_H

#include "pidatetime.h"

//! \~\ingroup Types
//! \~english Precise sleep for "usecs" microseconds
//! \~russian Точно ожидает "usecs" микросекунд
PIP_EXPORT void piUSleep(int usecs); // on !Windows consider constant "usleep" offset

//! \~\ingroup Types
//! \brief
//! \~english Precise sleep for "msecs" milliseconds
//! \~russian Точно ожидает "msecs" миллисекунд
//! \~\details
//! \~english This function exec \a piUSleep (msecs * 1000)
//! \~russian Этот метод вызывает \a piUSleep (msecs * 1000)
inline void piMSleep(double msecs) {
	piUSleep(int(msecs * 1000.));
} // on !Windows consider constant "usleep" offset

//! \~\ingroup Types
//! \brief
//! \~english Precise sleep for "secs" seconds
//! \~russian Точно ожидает "secs" секунд
//! \~\details
//! \~english This function exec \a piUSleep (msecs * 1000000)
//! \~russian Этот метод вызывает \a piUSleep (msecs * 1000000)
inline void piSleep(double secs) {
	piUSleep(int(secs * 1000000.));
} // on !Windows consider constant "usleep" offset

//! \~\ingroup Types
//! \brief
//! \~english Precise sleep for "t" time
//! \~russian Точно ожидает время "t"
inline void piSleep(PISystemTime t) {
	t.sleep();
}

//! \~\ingroup Types
//! \~english Shortest available on current system sleep
//! \~russian Наименее возможное для данной системы по длительности ожидание
inline void piMinSleep() {
	piMSleep(PIP_MIN_MSLEEP);
}

#endif // PITIME_H
