001    /*
002     * Copyright (c) 1998-2014 ChemAxon Ltd. All Rights Reserved.
003     *
004     * This software is the confidential and proprietary information of
005     * ChemAxon. You shall not disclose such Confidential Information
006     * and shall use it only in accordance with the terms of the agreements
007     * you entered into with ChemAxon.
008     *
009     */
010    package com.chemaxon.overlap.concurrent;
011    
012    import com.google.common.base.Function;
013    import java.util.Iterator;
014    
015    /**
016     * Abstraction of a mass processor.
017     *
018     *
019     * @author Gabor Imre
020     */
021    public interface Processor {
022    
023        /**
024         * Invoke blocking processing.
025         *
026         * <p>
027         * This method blocks until completion. The callbacks are invoked only on the main thread. Any exception thrown in
028         * the callbacks will propagate.</p>
029         *
030         * <p>
031         * Process function will possibly be invoked on multiple worker threads, it must be thread safe. Any exception will
032         * be recorded and reported later.</p>
033         *
034         * @param <S> Type of processed sources
035         * @param <T> Type of processed results
036         *
037         * @param source Source of inputs
038         * @param process Processing function
039         * @param error Error handler
040         * @param target Results handler
041         */
042        <S, T> void process(
043                Iterator<S> source,
044                Function<S, T> process,
045                ErrorHandler<S> error,
046                ResultHandler<S, T> target);
047    
048    }