PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/rt/sync/timer.h

http://github.com/jruderman/rust
C Header | 27 lines | 21 code | 3 blank | 3 comment | 0 complexity | 6d224ee38bc1509c68e621d8142d4cf8 MD5 | raw file
 1/*
 2 *  Utility class to measure time in a platform independent way.
 3 */
 4
 5#ifndef TIMER_H
 6#define TIMER_H
 7
 8class timer {
 9private:
10    uint64_t _start_us;
11    uint64_t _timeout_us;
12    uint64_t time_us();
13#if __WIN32__
14    uint64_t _ticks_per_s;
15#endif
16public:
17    timer();
18    void reset_us(uint64_t timeout);
19    uint64_t elapsed_us();
20    double elapsed_ms();
21    int64_t remaining_us();
22    bool has_timed_out();
23    uint64_t time_ns();
24    virtual ~timer();
25};
26
27#endif /* TIMER_H */