Path: blob/master/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/check/PhantomizationServiceThread.java
41161 views
/*1* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/22package gc.g1.unloading.check;232425import gc.g1.unloading.ExecutionTask;2627import java.lang.ref.Reference;28import java.lang.ref.ReferenceQueue;29import java.util.*;3031import nsk.share.test.ExecutionController;3233/**34* This thread listens to queue of phantomized classloaders and marks corresponding assertions as passed.35*/36public class PhantomizationServiceThread extends ExecutionTask {3738private static final int TIMEOUT = 100;3940private Map<Reference<?>, PhantomizedAssertion> map = new HashMap<>();4142private ReferenceQueue queue = new ReferenceQueue();4344public PhantomizationServiceThread(ExecutionController executionController) {45super(executionController);46}4748public void add(Reference ref, PhantomizedAssertion assertion) {49map.put(ref, assertion);50}5152public ReferenceQueue getQueue() {53return queue;54}5556@Override57protected void task() throws Exception {58Reference ref = queue.remove(TIMEOUT);59PhantomizedAssertion assertion = map.remove(ref);60if (assertion != null) {61assertion.setPhantomized();62}63}6465}666768