001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.jikesrvm.adaptive.measurements.organizers;
014
015 import org.jikesrvm.adaptive.measurements.RuntimeMeasurements;
016 import org.jikesrvm.adaptive.measurements.listeners.YieldCounterListener;
017 import org.vmmagic.pragma.NonMoving;
018
019 /**
020 * An organizer that periodically decays runtime counters
021 *
022 **/
023 @NonMoving
024 public final class DecayOrganizer extends Organizer {
025
026 /**
027 * @param listener the associated listener
028 */
029 public DecayOrganizer(YieldCounterListener listener) {
030 this.listener = listener;
031 listener.setOrganizer(this);
032 makeDaemon(true);
033 }
034
035 /**
036 * Initialization: install and activate our listener.
037 */
038 @Override
039 public void initialize() {
040 RuntimeMeasurements.installTimerNullListener((YieldCounterListener) listener);
041 }
042
043 /**
044 * Method that is called when the sampling threshold is reached
045 * We decay the decayable objects and activate the listener again.
046 */
047 void thresholdReached() {
048 RuntimeMeasurements.decayDecayableObjects();
049 }
050 }
051
052
053