Adds a modified copy of talk/base to webrtc/base. It is the first step in migrating talk/base to webrtc/base.
BUG=N/A R=andrew@webrtc.org, wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12199004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6107 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
59
webrtc/base/timing.h
Normal file
59
webrtc/base/timing.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.
|
||||
virtual 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_
|
||||
Reference in New Issue
Block a user