Path: blob/master/runtime/gc_realtime/Timer.hpp
5985 views
/*******************************************************************************1* Copyright (c) 1991, 2019 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception20*******************************************************************************/2122#if !defined(TIMER_HPP_)23#define TIMER_HPP_2425#include "Metronome.hpp"2627class MM_EnvironmentBase;28class MM_OSInterface;2930class MM_Timer : public MM_BaseVirtual31{32/* Data members & types */33public:34protected:35private:36U_64 _tickBase; /**< Current tick count from the TSC */37U_64 _sytemTimeBase; /**< Current system time in nanoseconds */38MM_OSInterface* _osInterface; /**< OS Interface used to set the time base on reset/initialize. */3940/* Methods */41public:42static MM_Timer* newInstance(MM_EnvironmentBase* env, MM_OSInterface* osInterface);43virtual void kill(MM_EnvironmentBase* env);4445U_64 peekElapsedTime(U_64 base);46U_64 getTimeInNanos();47U_64 nanoTime();48void reset();49bool hasTimeElapsed(U_64 startTimeInNanos, U_64 timeToWaitInNanos);5051protected:52bool initialize(MM_EnvironmentBase* env, MM_OSInterface* osInterface);53void tearDown(MM_EnvironmentBase* env);54private:55U_64 rebaseTime();5657MM_Timer() :58_tickBase(J9CONST64(0)),59_sytemTimeBase(J9CONST64(0)),60_osInterface(NULL)61{62_typeId = __FUNCTION__;63}6465};6667#endif /*TIMER_HPP_*/686970