MCPcopy Create free account
hub / github.com/apache/mesos / Time

Class Time

3rdparty/libprocess/include/process/time.hpp:23–85  ·  view source on GitHub ↗

Represents an instant in time.

Source from the content-addressed store, hash-verified

21
22// Represents an instant in time.
23class Time
24{
25public:
26 // Constructs a time at the Epoch. It is needed because collections
27 // (e.g., std::map) require a default constructor to construct
28 // empty values.
29 Time() : sinceEpoch(Duration::zero()) {}
30
31 static Time epoch();
32 static Time max();
33
34 static Try<Time> create(double seconds);
35
36 Duration duration() const { return sinceEpoch; }
37
38 double secs() const { return sinceEpoch.secs(); }
39
40 bool operator<(const Time& t) const { return sinceEpoch < t.sinceEpoch; }
41 bool operator<=(const Time& t) const { return sinceEpoch <= t.sinceEpoch; }
42 bool operator>(const Time& t) const { return sinceEpoch > t.sinceEpoch; }
43 bool operator>=(const Time& t) const { return sinceEpoch >= t.sinceEpoch; }
44 bool operator==(const Time& t) const { return sinceEpoch == t.sinceEpoch; }
45 bool operator!=(const Time& t) const { return sinceEpoch != t.sinceEpoch; }
46
47 Time& operator+=(const Duration& d)
48 {
49 sinceEpoch += d;
50 return *this;
51 }
52
53 Time& operator-=(const Duration& d)
54 {
55 sinceEpoch -= d;
56 return *this;
57 }
58
59 Duration operator-(const Time& that) const
60 {
61 return sinceEpoch - that.sinceEpoch;
62 }
63
64 Time operator+(const Duration& duration) const
65 {
66 Time new_ = *this;
67 new_ += duration;
68 return new_;
69 }
70
71 Time operator-(const Duration& duration) const
72 {
73 Time new_ = *this;
74 new_ -= duration;
75 return new_;
76 }
77
78private:
79 Duration sinceEpoch;
80

Callers 5

epochMethod · 0.70
maxMethod · 0.70
synchronizedFunction · 0.50
createMethod · 0.50
FrameworkMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected