
There's no need to construct a Timing object to call this method. On Windows we were unnecessarily calling CreateWaitableTimer + CloseHandle but never actually using that waitable timer. There's otherwise no change in functionality. R=xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/20869004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6624 4adac7df-926f-26a2-2b94-8c16560cd09d
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
/*
|
|
* Copyright 2008 The WebRTC Project Authors. All rights reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_BASE_TIMING_H_
|
|
#define WEBRTC_BASE_TIMING_H_
|
|
|
|
#if defined(WEBRTC_WIN)
|
|
#include "webrtc/base/win32.h"
|
|
#endif
|
|
|
|
namespace rtc {
|
|
|
|
class Timing {
|
|
public:
|
|
Timing();
|
|
virtual ~Timing();
|
|
|
|
// WallTimeNow() returns the current wall-clock time in seconds,
|
|
// within 10 milliseconds resolution.
|
|
// WallTimeNow is static and does not require a timer_handle_ on Windows.
|
|
static double WallTimeNow();
|
|
|
|
// TimerNow() is like WallTimeNow(), but is monotonically
|
|
// increasing. It returns seconds in resolution of 10 microseconds
|
|
// or better. Although timer and wall-clock time have the same
|
|
// timing unit, they do not necessarily correlate because wall-clock
|
|
// time may be adjusted backwards, hence not monotonic.
|
|
// Made virtual so we can make a fake one.
|
|
virtual double TimerNow();
|
|
|
|
// BusyWait() exhausts CPU as long as the time elapsed is less than
|
|
// the specified interval in seconds. Returns the actual waiting
|
|
// time based on TimerNow() measurement.
|
|
double BusyWait(double period);
|
|
|
|
// IdleWait() relinquishes control of CPU for specified period in
|
|
// seconds. It uses highest resolution sleep mechanism as possible,
|
|
// but does not otherwise guarantee the accuracy. Returns the
|
|
// actual waiting time based on TimerNow() measurement.
|
|
//
|
|
// This function is not re-entrant for an object. Create a fresh
|
|
// Timing object for each thread.
|
|
double IdleWait(double period);
|
|
|
|
private:
|
|
#if defined(WEBRTC_WIN)
|
|
HANDLE timer_handle_;
|
|
#endif
|
|
};
|
|
|
|
} // namespace rtc
|
|
|
|
#endif // WEBRTC_BASE_TIMING_H_
|