Remove dead code from webrtc/base/timing.*

BUG=

Review URL: https://codereview.webrtc.org/1626253002

Cr-Commit-Position: refs/heads/master@{#11366}
This commit is contained in:
tommi
2016-01-25 03:09:29 -08:00
committed by Commit bot
parent 9de632a100
commit 7d0d0e0763
2 changed files with 5 additions and 84 deletions

View File

@ -21,30 +21,13 @@
#endif
#elif defined(WEBRTC_WIN)
#include <sys/timeb.h>
#include "webrtc/base/win32.h"
#endif
namespace rtc {
Timing::Timing() {
#if defined(WEBRTC_WIN)
// This may fail, but we handle failure gracefully in the methods
// that use it (use alternative sleep method).
//
// TODO: Make it possible for user to tell if IdleWait will
// be done at lesser resolution because of this.
timer_handle_ = CreateWaitableTimer(NULL, // Security attributes.
FALSE, // Manual reset?
NULL); // Timer name.
#endif
}
Timing::Timing() {}
Timing::~Timing() {
#if defined(WEBRTC_WIN)
if (timer_handle_ != NULL)
CloseHandle(timer_handle_);
#endif
}
Timing::~Timing() {}
// static
double Timing::WallTimeNow() {
@ -68,46 +51,4 @@ double Timing::TimerNow() {
return (static_cast<double>(TimeNanos()) / kNumNanosecsPerSec);
}
double Timing::BusyWait(double period) {
double start_time = TimerNow();
while (TimerNow() - start_time < period) {
}
return TimerNow() - start_time;
}
double Timing::IdleWait(double period) {
double start_time = TimerNow();
#if defined(WEBRTC_POSIX)
double sec_int, sec_frac = modf(period, &sec_int);
struct timespec ts;
ts.tv_sec = static_cast<time_t>(sec_int);
ts.tv_nsec = static_cast<long>(sec_frac * 1.0e9); // NOLINT
// NOTE(liulk): for the NOLINT above, long is the appropriate POSIX
// type.
// POSIX nanosleep may be interrupted by signals.
while (nanosleep(&ts, &ts) == -1 && errno == EINTR) {
}
#elif defined(WEBRTC_WIN)
if (timer_handle_ != NULL) {
LARGE_INTEGER due_time;
// Negative indicates relative time. The unit is 100 nanoseconds.
due_time.QuadPart = -LONGLONG(period * 1.0e7);
SetWaitableTimer(timer_handle_, &due_time, 0, NULL, NULL, TRUE);
WaitForSingleObject(timer_handle_, INFINITE);
} else {
// Still attempts to sleep with lesser resolution.
// The unit is in milliseconds.
Sleep(DWORD(period * 1.0e3));
}
#endif
return TimerNow() - start_time;
}
} // namespace rtc

View File

@ -11,10 +11,6 @@
#ifndef WEBRTC_BASE_TIMING_H_
#define WEBRTC_BASE_TIMING_H_
#if defined(WEBRTC_WIN)
#include "webrtc/base/win32.h"
#endif
namespace rtc {
class Timing {
@ -33,26 +29,10 @@ class Timing {
// 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.
// TODO(tommi): The only place we use this (virtual) is in
// rtpdata_engine_unittest.cc. See if it doesn't make more sense to change
// that contract or test than to modify this generic class.
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