Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_realtime/Timer.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2019 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* 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-exception
21
*******************************************************************************/
22
23
#if !defined(TIMER_HPP_)
24
#define TIMER_HPP_
25
26
#include "Metronome.hpp"
27
28
class MM_EnvironmentBase;
29
class MM_OSInterface;
30
31
class MM_Timer : public MM_BaseVirtual
32
{
33
/* Data members & types */
34
public:
35
protected:
36
private:
37
U_64 _tickBase; /**< Current tick count from the TSC */
38
U_64 _sytemTimeBase; /**< Current system time in nanoseconds */
39
MM_OSInterface* _osInterface; /**< OS Interface used to set the time base on reset/initialize. */
40
41
/* Methods */
42
public:
43
static MM_Timer* newInstance(MM_EnvironmentBase* env, MM_OSInterface* osInterface);
44
virtual void kill(MM_EnvironmentBase* env);
45
46
U_64 peekElapsedTime(U_64 base);
47
U_64 getTimeInNanos();
48
U_64 nanoTime();
49
void reset();
50
bool hasTimeElapsed(U_64 startTimeInNanos, U_64 timeToWaitInNanos);
51
52
protected:
53
bool initialize(MM_EnvironmentBase* env, MM_OSInterface* osInterface);
54
void tearDown(MM_EnvironmentBase* env);
55
private:
56
U_64 rebaseTime();
57
58
MM_Timer() :
59
_tickBase(J9CONST64(0)),
60
_sytemTimeBase(J9CONST64(0)),
61
_osInterface(NULL)
62
{
63
_typeId = __FUNCTION__;
64
}
65
66
};
67
68
#endif /*TIMER_HPP_*/
69
70