From 0a1baef4f57b4ac8558a65b7bd8dc787ebf54840 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 22 Aug 2013 22:29:04 -0700 Subject: rt: Remove timer --- src/rt/sync/timer.cpp | 85 --------------------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 src/rt/sync/timer.cpp (limited to 'src/rt/sync/timer.cpp') diff --git a/src/rt/sync/timer.cpp b/src/rt/sync/timer.cpp deleted file mode 100644 index 99e5b107dc9..00000000000 --- a/src/rt/sync/timer.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include "../rust_globals.h" -#include "timer.h" - -#if defined(__APPLE__) -#include -#endif - -uint64_t ns_per_s = 1000000000LL; - -timer::timer() { -#if __WIN32__ - _ticks_per_s = 0LL; - // FIXME (#2675): assert this works or have a workaround. - QueryPerformanceFrequency((LARGE_INTEGER *)&_ticks_per_s); - if (_ticks_per_s == 0LL) { - _ticks_per_s = 1LL; - } -#endif - reset_us(0); -} - -void -timer::reset_us(uint64_t timeout_us) { - _start_us = time_us(); - _timeout_us = timeout_us; -} - -uint64_t -timer::elapsed_us() { - return time_us() - _start_us; -} - -double -timer::elapsed_ms() { - return (double) elapsed_us() / 1000.0; -} - -int64_t -timer::remaining_us() { - return _timeout_us - elapsed_us(); -} - -bool -timer::has_timed_out() { - return remaining_us() <= 0; -} - -uint64_t -timer::time_ns() { -#ifdef __APPLE__ - uint64_t time = mach_absolute_time(); - mach_timebase_info_data_t info = {0, 0}; - if (info.denom == 0) { - mach_timebase_info(&info); - } - uint64_t time_nano = time * (info.numer / info.denom); - return time_nano; -#elif __WIN32__ - uint64_t ticks; - QueryPerformanceCounter((LARGE_INTEGER *)&ticks); - return ((ticks * ns_per_s) / _ticks_per_s); -#else - timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return (ts.tv_sec * ns_per_s + ts.tv_nsec); -#endif -} - -uint64_t -timer::time_us() { - return time_ns() / 1000; -} - -timer::~timer() { -} -- cgit 1.4.1-3-g733a5