package meerkat.bulletinboard;

/**
 * Created by Arbel Deutsch Peled on 09-Dec-15.
 *
 * This class handles bulletin client work.
 * It is meant to be used in a multi-threaded environment.
 */
public abstract class BulletinClientWorker<IN> {

    protected final IN payload;    // Payload of the job

    private int maxRetry;   // Number of retries for this job; set to -1 for infinite retries

    public BulletinClientWorker(IN payload, int maxRetry) {
        this.payload = payload;
        this.maxRetry = maxRetry;
    }

    public IN getPayload() {
        return payload;
    }

    public int getMaxRetry() {
        return maxRetry;
    }

    public void decMaxRetry(){
        if (maxRetry > 0) {
            maxRetry--;
        }
    }

    public boolean isRetry(){
        return (maxRetry != 0);
    }

}
