Path: blob/master/runtime/gc_base/FinalizableClassLoaderBuffer.hpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2014 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* @ingroup GC_Base26*/2728#if !defined(FINALIZABLECLASSLOADERBUFFER_HPP_)29#define FINALIZABLECLASSLOADERBUFFER_HPP_3031#include "j9.h"3233#include "FinalizeListManager.hpp"3435class GC_FinalizableClassLoaderBuffer36{37private:38J9ClassLoader *_head; /**< the head of the linked list of J9ClassLoader */39J9ClassLoader *_tail; /**< the tail of the linked list of J9ClassLoader */40UDATA _count; /**< the number of buffered J9ClassLoader */41MM_GCExtensions * const _extensions; /**< a cached pointer to the extensions structure */42protected:43public:4445private:46protected:47public:48/**49* Add the specified reference object to the buffer.50* @param env[in] the current thread51* @param object[in] the object to add52*/53void add(MM_EnvironmentBase* env, J9ClassLoader *loader)54{55if (NULL == _head) {56Assert_MM_true(NULL == _tail);57Assert_MM_true(0 == _count);58loader->unloadLink = NULL;59_head = loader;60_tail = loader;61_count = 1;62} else {63Assert_MM_true(NULL != _tail);64Assert_MM_true(0 != _count);65loader->unloadLink = _head;66_head = loader;67_count += 1;68}69}7071void flush(MM_EnvironmentBase* env)72{73if (NULL != _head) {74Assert_MM_true(NULL != _tail);75Assert_MM_true(0 != _count);76GC_FinalizeListManager *finalizeListManager = _extensions->finalizeListManager;77finalizeListManager->addClassLoaders(_head, _tail, _count);78_head = NULL;79_tail = NULL;80_count = 0;81}82}8384/**85* Construct a new buffer.86* @param extensions[in] the GC extensions87*/88GC_FinalizableClassLoaderBuffer(MM_GCExtensions *extensions) :89_head(NULL)90,_tail(NULL)91,_count(0)92,_extensions(extensions)93{}94};95#endif /* FINALIZABLECLASSLOADERBUFFER_HPP_ */969798