Path: blob/master/runtime/gc_realtime/MetronomeAlarmThread.hpp
5986 views
1/*******************************************************************************2* Copyright (c) 1991, 2019 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* 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 and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*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-exception21*******************************************************************************/2223/**24* @file25*/2627#if !defined(METRONOMEALARMTHREAD_HPP_)28#define METRONOMEALARMTHREAD_HPP_2930#include "omr.h"31#include "omrcfg.h"3233#include "ProcessorInfo.hpp"34#include "MetronomeAlarm.hpp"35#include "EnvironmentRealtime.hpp"3637class MM_Timer;3839class MM_MetronomeAlarmThread : public MM_BaseVirtual40{41/*42* Data members43*/44private:45MM_Alarm *_alarm;46omrthread_monitor_t _mutex;47volatile bool _shutdown;48enum AlarmThreadActive {49ALARM_THREAD_INACTIVE,50ALARM_THREAD_ACTIVE,51ALARM_THREAD_SHUTDOWN52};53volatile AlarmThreadActive _alarmThreadActive;54MM_Scheduler *_scheduler;5556protected:57public:58omrthread_t _thread; /**< Underlying port-library thread */5960/*61* Function members62*/63private:64static int J9THREAD_PROC metronomeAlarmThreadWrapper(void* userData);6566protected:67void tearDown(MM_EnvironmentBase *env);68bool initialize (MM_EnvironmentBase *env);6970public:71static MM_MetronomeAlarmThread *newInstance(MM_EnvironmentBase *env);72virtual void kill(MM_EnvironmentBase *env);7374MM_Scheduler* getScheduler() const { return _scheduler; }7576bool startThread(MM_EnvironmentBase *env);77virtual void run(MM_EnvironmentRealtime *env);7879MM_MetronomeAlarmThread(MM_EnvironmentBase *env)80: MM_BaseVirtual()81, _alarm(NULL)82, _mutex(NULL)83, _shutdown(false)84, _alarmThreadActive(ALARM_THREAD_INACTIVE)85, _scheduler((MM_Scheduler *)(MM_GCExtensionsBase::getExtensions(env->getOmrVM())->dispatcher))86, _thread(NULL)87{88_typeId = __FUNCTION__;89}9091/*92* Friends93*/94friend class MM_Scheduler;95friend class MM_MetronomeDelegate;96};9798#endif /* METRONOMEALARMTHREAD_HPP_ */99100101102