Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_realtime/MetronomeAlarmThread.hpp
5986 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2019 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* 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
22
*******************************************************************************/
23
24
/**
25
* @file
26
*/
27
28
#if !defined(METRONOMEALARMTHREAD_HPP_)
29
#define METRONOMEALARMTHREAD_HPP_
30
31
#include "omr.h"
32
#include "omrcfg.h"
33
34
#include "ProcessorInfo.hpp"
35
#include "MetronomeAlarm.hpp"
36
#include "EnvironmentRealtime.hpp"
37
38
class MM_Timer;
39
40
class MM_MetronomeAlarmThread : public MM_BaseVirtual
41
{
42
/*
43
* Data members
44
*/
45
private:
46
MM_Alarm *_alarm;
47
omrthread_monitor_t _mutex;
48
volatile bool _shutdown;
49
enum AlarmThreadActive {
50
ALARM_THREAD_INACTIVE,
51
ALARM_THREAD_ACTIVE,
52
ALARM_THREAD_SHUTDOWN
53
};
54
volatile AlarmThreadActive _alarmThreadActive;
55
MM_Scheduler *_scheduler;
56
57
protected:
58
public:
59
omrthread_t _thread; /**< Underlying port-library thread */
60
61
/*
62
* Function members
63
*/
64
private:
65
static int J9THREAD_PROC metronomeAlarmThreadWrapper(void* userData);
66
67
protected:
68
void tearDown(MM_EnvironmentBase *env);
69
bool initialize (MM_EnvironmentBase *env);
70
71
public:
72
static MM_MetronomeAlarmThread *newInstance(MM_EnvironmentBase *env);
73
virtual void kill(MM_EnvironmentBase *env);
74
75
MM_Scheduler* getScheduler() const { return _scheduler; }
76
77
bool startThread(MM_EnvironmentBase *env);
78
virtual void run(MM_EnvironmentRealtime *env);
79
80
MM_MetronomeAlarmThread(MM_EnvironmentBase *env)
81
: MM_BaseVirtual()
82
, _alarm(NULL)
83
, _mutex(NULL)
84
, _shutdown(false)
85
, _alarmThreadActive(ALARM_THREAD_INACTIVE)
86
, _scheduler((MM_Scheduler *)(MM_GCExtensionsBase::getExtensions(env->getOmrVM())->dispatcher))
87
, _thread(NULL)
88
{
89
_typeId = __FUNCTION__;
90
}
91
92
/*
93
* Friends
94
*/
95
friend class MM_Scheduler;
96
friend class MM_MetronomeDelegate;
97
};
98
99
#endif /* METRONOMEALARMTHREAD_HPP_ */
100
101
102