package com.tsi.comm.server.process;

import lombok.Getter;
import lombok.Setter;

@Getter
public abstract class AbstractTsiCvimWorker {

    protected long avgTime = 0;
    protected int idx;
    protected int qSize;
    protected long processedCount = 0L;
    @Setter
    protected int jobs;

    public abstract boolean add(Object packet);
    public abstract void process(Object packet);
    public abstract void report();

    protected long calcProcessTime(long recvTime) {
        long jobTime = System.nanoTime() - recvTime;
        if (this.avgTime == 0) {
            this.avgTime = jobTime;
        }
        else {
            this.avgTime = (this.avgTime + jobTime) / 2L;
        }
        this.processedCount++;
        return this.avgTime;
    }

}
