All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.truevfs.ext.pacemaker.PaceModel Maven / Gradle / Ivy

Go to download

Constrains the number of concurrently mounted archive file systems in order to save some heap space. This module provides a JMX interface for monitoring and management. Add the JAR artifact of this module to the run time class path to make its services available for service location in the client API modules.

The newest version!
/*
 * Copyright © 2005 - 2021 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package net.java.truevfs.ext.pacemaker;

import lombok.val;
import net.java.truevfs.comp.inst.InstrumentingModel;
import net.java.truevfs.kernel.spec.FsModel;
import net.java.truevfs.kernel.spec.FsMountPoint;

/**
 * A pace model.
 *
 * @author Christian Schlichtherle
 */
final class PaceModel extends InstrumentingModel {

    private final LruCache cachedMountPoints;

    PaceModel(PaceMediator mediator, FsModel model) {
        super(mediator, model);
        this.cachedMountPoints = mediator.cachedMountPoints;
    }

    @Override
    public void setMounted(final boolean isMounted) {
        val wasMounted = model.isMounted();
        model.setMounted(isMounted);
        if (wasMounted) {
            if (!isMounted) {
                cachedMountPoints.remove(getMountPoint());
            }
        } else {
            if (isMounted) {
                cachedMountPoints.add(getMountPoint());
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy