OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 // For timing sensitive unittests, this function should be used. | 215 // For timing sensitive unittests, this function should be used. |
216 static Time NowFromSystemTime(); | 216 static Time NowFromSystemTime(); |
217 | 217 |
218 // Returns the time for epoch in Unix-like system (Jan 1, 1970). | 218 // Returns the time for epoch in Unix-like system (Jan 1, 1970). |
219 static Time UnixEpoch() { return Time(0); } | 219 static Time UnixEpoch() { return Time(0); } |
220 | 220 |
221 // Returns the maximum time, which should be greater than any reasonable time | 221 // Returns the maximum time, which should be greater than any reasonable time |
222 // with which we might compare it. | 222 // with which we might compare it. |
223 static Time Max() { return Time(std::numeric_limits<int64_t>::max()); } | 223 static Time Max() { return Time(std::numeric_limits<int64_t>::max()); } |
224 | 224 |
225 // Converts to/from internal values. The meaning of the "internal value" is | |
226 // completely up to the implementation, so it should be treated as opaque. | |
227 static Time FromInternalValue(int64_t value) V8_WARN_UNUSED_RESULT { | |
Michael Starzinger
2013/09/09 17:11:25
Ceterum censeo V8_WARN_UNUSED_RESULT esse delendam
Benedikt Meurer
2013/09/10 06:08:07
Done.
| |
228 return Time(value); | |
229 } | |
230 int64_t ToInternalValue() const V8_WARN_UNUSED_RESULT { | |
Michael Starzinger
2013/09/09 17:11:25
Ceterum censeo V8_WARN_UNUSED_RESULT esse delendam
Benedikt Meurer
2013/09/10 06:08:07
Done.
| |
231 return us_; | |
232 } | |
233 | |
225 // Converts to/from POSIX time specs. | 234 // Converts to/from POSIX time specs. |
226 static Time FromTimespec(struct timespec ts); | 235 static Time FromTimespec(struct timespec ts); |
227 struct timespec ToTimespec() const; | 236 struct timespec ToTimespec() const; |
228 | 237 |
229 // Converts to/from POSIX time values. | 238 // Converts to/from POSIX time values. |
230 static Time FromTimeval(struct timeval tv); | 239 static Time FromTimeval(struct timeval tv); |
231 struct timeval ToTimeval() const; | 240 struct timeval ToTimeval() const; |
232 | 241 |
233 // Converts to/from Windows file times. | 242 // Converts to/from Windows file times. |
234 static Time FromFiletime(struct _FILETIME ft); | 243 static Time FromFiletime(struct _FILETIME ft); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 // Returns a platform-dependent high-resolution tick count. Implementation | 331 // Returns a platform-dependent high-resolution tick count. Implementation |
323 // is hardware dependent and may or may not return sub-millisecond | 332 // is hardware dependent and may or may not return sub-millisecond |
324 // resolution. THIS CALL IS GENERALLY MUCH MORE EXPENSIVE THAN Now() AND | 333 // resolution. THIS CALL IS GENERALLY MUCH MORE EXPENSIVE THAN Now() AND |
325 // SHOULD ONLY BE USED WHEN IT IS REALLY NEEDED. | 334 // SHOULD ONLY BE USED WHEN IT IS REALLY NEEDED. |
326 // This method never returns a null TimeTicks. | 335 // This method never returns a null TimeTicks. |
327 static TimeTicks HighResNow(); | 336 static TimeTicks HighResNow(); |
328 | 337 |
329 // Returns true if this object has not been initialized. | 338 // Returns true if this object has not been initialized. |
330 bool IsNull() const { return ticks_ == 0; } | 339 bool IsNull() const { return ticks_ == 0; } |
331 | 340 |
341 // Converts to/from internal values. The meaning of the "internal value" is | |
342 // completely up to the implementation, so it should be treated as opaque. | |
343 static TimeTicks FromInternalValue(int64_t value) V8_WARN_UNUSED_RESULT { | |
Michael Starzinger
2013/09/09 17:11:25
Ceterum censeo V8_WARN_UNUSED_RESULT esse delendam
Benedikt Meurer
2013/09/10 06:08:07
Done.
| |
344 return TimeTicks(value); | |
345 } | |
346 int64_t ToInternalValue() const V8_WARN_UNUSED_RESULT { | |
Michael Starzinger
2013/09/09 17:11:25
Ceterum censeo V8_WARN_UNUSED_RESULT esse delendam
Benedikt Meurer
2013/09/10 06:08:07
Done.
| |
347 return ticks_; | |
348 } | |
349 | |
332 TimeTicks& operator=(const TimeTicks other) { | 350 TimeTicks& operator=(const TimeTicks other) { |
333 ticks_ = other.ticks_; | 351 ticks_ = other.ticks_; |
334 return *this; | 352 return *this; |
335 } | 353 } |
336 | 354 |
337 // Compute the difference between two times. | 355 // Compute the difference between two times. |
338 TimeDelta operator-(const TimeTicks other) const { | 356 TimeDelta operator-(const TimeTicks other) const { |
339 return TimeDelta::FromMicroseconds(ticks_ - other.ticks_); | 357 return TimeDelta::FromMicroseconds(ticks_ - other.ticks_); |
340 } | 358 } |
341 | 359 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 int64_t ticks_; | 404 int64_t ticks_; |
387 }; | 405 }; |
388 | 406 |
389 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { | 407 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { |
390 return ticks + delta; | 408 return ticks + delta; |
391 } | 409 } |
392 | 410 |
393 } } // namespace v8::internal | 411 } } // namespace v8::internal |
394 | 412 |
395 #endif // V8_PLATFORM_TIME_H_ | 413 #endif // V8_PLATFORM_TIME_H_ |
OLD | NEW |