package com.atlassian.stash.internal.concurrent;

/**
 * Interface for thread pools that is used to define the methods/attributes that should be exposed to JMX. This is an {@code MXBean} to ensure
 * the broadest remote client compatibility.
 * @since 3.8
 */
// Used via JMX
public interface ThreadPoolMXBean {
    /**
     * Returns the approximate number of threads that are actively
     * executing tasks.
     *
     * @return the number of threads
     */
    public int getActiveCount();

    /**
     * Returns the number of work items that are awaiting processing.
     *
     * @return the length of the work item queue.
     */
    public int getQueueLength();

    /**
     * Returns the current number of threads in the pool.
     *
     * @return the number of threads
     */
    public int getPoolSize();

    /**
     * Returns the maximum allowed number of threads.
     *
     * @return the maximum allowed number of threads
     * @see java.util.concurrent.ThreadPoolExecutor#setMaximumPoolSize
     */
    public int getMaximumPoolSize();

    /**
     * Returns the largest number of threads that have ever
     * simultaneously been in the pool.
     *
     * @return the number of threads
     */
    public int getLargestPoolSize();

    /**
     * Returns the approximate total number of tasks that have
     * completed execution. Because the states of tasks and threads
     * may change dynamically during computation, the returned value
     * is only an approximation, but one that does not ever decrease
     * across successive calls.
     *
     * @return the number of tasks
     */
    public long getCompletedTaskCount();

    /**
     * Returns the approximate total number of tasks that have ever been
     * scheduled for execution. Because the states of tasks and
     * threads may change dynamically during computation, the returned
     * value is only an approximation.
     *
     * @return the number of tasks
     */
    public long getTaskCount();
}
