package net.ranides.assira.functional.special;

import java.util.function.Consumer;

/**
 * This interface represents Runnable task which can be canceled.
 * It is used by TaskInvoker.
 */
public interface CancelableConsumer<T> extends Consumer<T> {

    /**
     * Cancels execution
     * Returns false if it is impossible to cancel because it is already canceled or finished.
     *
     * @return boolean
     */
    boolean cancel();

    /**
     * Returns true if it is finished successfully.
     *
     * @return boolean
     */
    boolean isDone();

    /**
     * Returns true if it was canceled.
     *
     * @return boolean
     */
    boolean isCanceled();

}
