package com.it_jaros.jscanner.scan.engine;
import java.time.Duration;
import java.util.Iterator;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
public class ProducerThread {
public static final Duration pollInterval = Duration.ofSeconds(1);
private final ExecutorService executor;
private final CancelledToken cancelledToken;
public ProducerThread(ScanExecutionContext context) {
this.executor = context.executorService();
this.cancelledToken = context.cancelledToken();
}
/**
* This method helps to cleanup the code a bit and remove redundancy
* The producer for providing hosts and the one for providing ports
* are similar and the small differences can be handled using a function
*
* @param queue
* @param maxWorkers
* @param taskFactory
* @param
* @param