OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_RTC_BASE_TIME_INTERVAL_H_ | |
ossu
2017/07/14 11:13:15
I'm not sure if this class belongs in rtc_base jus
saza WebRTC
2017/07/17 14:27:29
Done.
| |
12 #define WEBRTC_RTC_BASE_TIME_INTERVAL_H_ | |
13 | |
14 #include <stdint.h> | |
15 | |
16 #include "webrtc/rtc_base/optional.h" | |
17 | |
18 namespace rtc { | |
19 | |
20 // This class logs the first and last time its Extend() function is called. | |
21 // Extend(...) takes arbitrary times. | |
22 // | |
23 // This class is not thread-safe; Extend() should only be used when only one | |
24 // thread may access it, such as within a lock or destructor. | |
25 // | |
26 // Example usage: | |
27 // // let x < y < z < u < v | |
28 // rtc::TimeInterval interval; | |
29 // ... // interval.Extend(); // at time x | |
30 // ... | |
31 // interval.Extend(); // at time y | |
32 // ... | |
33 // interval.Extend(); // at time u | |
34 // ... | |
35 // interval.Extend(z); // at time v | |
36 // ... | |
37 // rtc::Optional<int64_t> first = interval.First(); | |
38 // rtc::Optional<int64_t> last = interval.Last(); | |
39 // if (first) { | |
40 // int64_t active_time = *last - *first; // returns (u - x) | |
41 // } | |
42 class TimeInterval { | |
43 public: | |
44 TimeInterval(); | |
45 ~TimeInterval(); | |
46 // Extend the interval with the current time. | |
47 void Extend(); | |
48 // Extend the interval with a given time. | |
49 void Extend(int64_t time); | |
pbos-webrtc
2017/07/14 17:04:01
Should Extend not be able to take another time int
saza WebRTC
2017/07/17 14:27:29
Done.
| |
50 // True iff Extend has never been called. | |
51 bool Empty() const; | |
52 // Returns the time of the first tick in milliseconds. | |
53 Optional<int64_t> First() const; | |
54 // Returns the time of the last tick in milliseconds. | |
55 Optional<int64_t> Last() const; | |
56 | |
57 private: | |
58 Optional<int64_t> first_; | |
59 Optional<int64_t> last_; | |
60 }; | |
61 | |
62 } // namespace rtc | |
63 | |
64 #endif // WEBRTC_RTC_BASE_TIME_INTERVAL_H_ | |
OLD | NEW |