source: box/trunk/lib/common/BoxTime.h @ 3084

Revision 3084, 1.3 KB checked in by chris, 3 months ago (diff)

Add experimental "TCP Nice" mode, disabled by default.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    BoxTime.h
5//              Purpose: How time is represented
6//              Created: 2003/10/08
7//
8// --------------------------------------------------------------------------
9
10#ifndef BOXTIME__H
11#define BOXTIME__H
12
13// Time is presented as an unsigned 64 bit integer, in microseconds
14typedef int64_t box_time_t;
15
16#define NANO_SEC_IN_SEC         (1000000000LL)
17#define NANO_SEC_IN_USEC        (1000)
18#define NANO_SEC_IN_USEC_LL (1000LL)
19#define MICRO_SEC_IN_SEC        (1000000)
20#define MICRO_SEC_IN_SEC_LL     (1000000LL)
21#define MILLI_SEC_IN_SEC                (1000)
22#define MILLI_SEC_IN_SEC_LL     (1000LL)
23
24box_time_t GetCurrentBoxTime();
25
26inline box_time_t SecondsToBoxTime(time_t Seconds)
27{
28        return ((box_time_t)Seconds * MICRO_SEC_IN_SEC_LL);
29}
30inline uint64_t MilliSecondsToBoxTime(int64_t milliseconds)
31{
32        return ((box_time_t)milliseconds * 1000);
33}
34inline time_t BoxTimeToSeconds(box_time_t Time)
35{
36        return Time / MICRO_SEC_IN_SEC_LL;
37}
38inline uint64_t BoxTimeToMilliSeconds(box_time_t Time)
39{
40        return Time / MILLI_SEC_IN_SEC_LL;
41}
42inline uint64_t BoxTimeToMicroSeconds(box_time_t Time)
43{
44        return Time;
45}
46
47std::string FormatTime(box_time_t time, bool includeDate,
48        bool showMicros = false);
49
50void ShortSleep(box_time_t duration, bool logDuration);
51
52#endif // BOXTIME__H
Note: See TracBrowser for help on using the repository browser.