📄 win32_timer.cpp
字号:
// This file is part of Ambulant Player, www.ambulantplayer.org.//// Copyright (C) 2003-2007 Stichting CWI, // Kruislaan 413, 1098 SJ Amsterdam, The Netherlands.//// Ambulant Player is free software; you can redistribute it and/or modify// it under the terms of the GNU Lesser General Public License as published by// the Free Software Foundation; either version 2.1 of the License, or// (at your option) any later version.//// Ambulant Player is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public License// along with Ambulant Player; if not, write to the Free Software// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA/* * @$Id: win32_timer.cpp,v 1.13 2007/02/12 14:15:04 jackjansen Exp $ */#include <windows.h>#include "ambulant/lib/win32/win32_timer.h"#include "ambulant/lib/logger.h"#include <cmath>using namespace ambulant;#ifdef AMBULANT_PLATFORM_WIN32_WCEstatic DWORDos_time() { return GetTickCount();}#elseconst ULONGLONG MILLIS_FACT = 10000;// Returns system time in system units (0.1 micro-sec units or 0.0001 msec). static DWORD os_time() { FILETIME ft; SYSTEMTIME st; GetSystemTime(&st); SystemTimeToFileTime(&st, &ft); ULARGE_INTEGER li = {ft.dwLowDateTime, ft.dwHighDateTime}; return (DWORD)(li.QuadPart/MILLIS_FACT);}#endiflib::win32::win32_timer::win32_timer() : m_epoch(os_time()) {}// Returns time in msec since epoch.// Takes into account speed with a 1% precision.lib::win32::win32_timer::time_typelib::win32::win32_timer::elapsed() const { assert((DWORD)m_epoch == m_epoch); DWORD dt = os_time() - (DWORD)m_epoch; return time_type(dt);}// Factory routine for the machine-independent// timer classlib::timer*lib::realtime_timer_factory() { return new lib::win32::win32_timer();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -