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

com.github.phantomthief.pool.impl.ConcurrencyAdjustStrategy Maven / Gradle / Ivy

There is a newer version: 0.1.19
Show newest version
package com.github.phantomthief.pool.impl;

import java.util.Collection;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * @author w.vela
 * Created on 2017-10-18.
 */
public interface ConcurrencyAdjustStrategy {

    AdjustResult NO_CHANGE = null;

    /**
     * @return {@link #NO_CHANGE} if no changed
     */
    @Nullable
    AdjustResult adjust(@Nonnull Collection current) throws Throwable;

    class AdjustResult {

        private final Collection evict;
        private final int create;

        /**
         * @param evict {@code null} if no item to evict
         */
        public AdjustResult(@Nullable Collection evict, int create) {
            this.evict = evict;
            this.create = create;
        }

        @Nullable
        Collection getEvict() {
            return evict;
        }

        int getCreate() {
            return create;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy