Program Listing for File cpuwatch_rt.hpp

Return to documentation for file (/tmp/ws/src/ecl_core/ecl_time/include/ecl/time/cpuwatch_rt.hpp)

/*****************************************************************************
** Ifdefs
*****************************************************************************/

#ifndef ECL_TIME_CPUWATCH_POS_HPP_
#define ECL_TIME_CPUWATCH_POS_HPP_

/*****************************************************************************
** Platform Check
*****************************************************************************/

#include <ecl/config.hpp>

#if defined(ECL_IS_POSIX)
  // monotonic clock, cpu clock -> clock_gettime; clock_selection -> clock_nanosleep
  #if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK) >= 0L && defined(_POSIX_CLOCK_SELECTION) && (_POSIX_CLOCK_SELECTION) >= 0L

/*****************************************************************************
** Includes
*****************************************************************************/

#include <ecl/config/macros.hpp>
#include "timestamp.hpp"
#include "macros.hpp"

/*****************************************************************************
** Namespaces
*****************************************************************************/

namespace ecl {

/*****************************************************************************
** Classes
*****************************************************************************/
class ecl_time_PUBLIC CpuWatch
{
    public:
        CpuWatch();

        virtual ~CpuWatch() {}
        void restart();

        TimeStamp elapsed();
        TimeStamp split();

    private:
        TimeStamp start_time, split_time;
        timespec tmp; // use for temporary cacluations.
};

} // namespace ecl

#endif /* MANY POSIX TIME REQ'MENTS */
#endif /* ECL_IS_POSIX */
#endif /* ECL_TIME_CPUWATCH_POS_HPP_ */