package io.domisum.lib.auxiliumlib.thread.multithreader.queues;

import io.domisum.lib.auxiliumlib.annotations.API;
import io.domisum.lib.auxiliumlib.thread.multithreader.MultithreaderQueue;

import java.util.Collection;
import java.util.Optional;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

@API
public class MultithreaderQueue_Collection<T>
	implements MultithreaderQueue<T>
{
	
	// STATE
	private final Queue<T> queue = new ConcurrentLinkedQueue<>();
	
	
	// INIT
	@API
	public MultithreaderQueue_Collection(Collection<T> collection)
	{
		queue.addAll(collection);
	}
	
	
	// QUEUE
	@Override
	public boolean areThereMoreElements()
	{
		return queue.size() > 0;
	}
	
	@Override
	public Optional<T> poll()
	{
		var calcNullable = queue.poll();
		return Optional.ofNullable(calcNullable);
	}
	
}

@@ -184,16 +184,229 @@
 rQueue;%0A
+import io.domisum.lib.auxiliumlib.util.TimeUtil;%0Aimport io.domisum.lib.auxiliumlib.util.math.MathUtil;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.time.Duration;%0Aimport java.time.Instant;
 %0Aimport 
@@ -624,78 +624,401 @@
 %0A%09%0A%09
-// STATE%0A%09private final Queue%3CT%3E queue = new ConcurrentLinkedQueue%3C%3E()
+private final Logger logger = LoggerFactory.getLogger(getClass());%0A%09%0A%09%0A%09// CONSTANTS%0A%09private static final Duration LOG_PROGRESS_INTERVAL = Duration.ofSeconds(5);%0A%09%0A%09// SETTINGS%0A%09private final boolean logProgress;%0A%09%0A%09// DATA%0A%09private final Queue%3CT%3E queue = new ConcurrentLinkedQueue%3C%3E();%0A%09private final int totalElementsCount;%0A%09%0A%09// STATUS%0A%09private Instant lastProgressLogInstant = Instant.MIN
 ;%0A%09%0A
@@ -1041,16 +1041,27 @@
 %0A%09public
+ static %3CT%3E
  Multith
@@ -1082,16 +1082,26 @@
 llection
+%3CT%3E create
 (Collect
@@ -1128,176 +1128,1060 @@
 %7B%0A%09%09
-queue.addAll(collection);%0A%09%7D%0A%09%0A%09%0A%09// QUEUE%0A%09@Override%0A%09public boolean areThereMoreElements()%0A%09%7B%0A%09%09return queue.size() %3E 0;%0A%09%7D%0A%09%0A%09@Override%0A%09public Optional%3CT%3E poll()%0A%09%7B
+return new MultithreaderQueue_Collection%3C%3E(false, collection);%0A%09%7D%0A%09%0A%09@API%0A%09public static %3CT%3E MultithreaderQueue_Collection%3CT%3E createWithLogProgress(Collection%3CT%3E collection)%0A%09%7B%0A%09%09return new MultithreaderQueue_Collection%3C%3E(false, collection);%0A%09%7D%0A%09%0A%09protected MultithreaderQueue_Collection(boolean logProgress, Collection%3CT%3E collection)%0A%09%7B%0A%09%09this.logProgress = logProgress;%0A%09%09queue.addAll(collection);%0A%09%09totalElementsCount = collection.size();%0A%09%7D%0A%09%0A%09%0A%09// QUEUE%0A%09@Override%0A%09public boolean areThereMoreElements()%0A%09%7B%0A%09%09return queue.size() %3E 0;%0A%09%7D%0A%09%0A%09@Override%0A%09public Optional%3CT%3E poll()%0A%09%7B%0A%09%09if(logProgress && TimeUtil.isOlderThan(lastProgressLogInstant, LOG_PROGRESS_INTERVAL))%0A%09%09%7B%0A%09%09%09int completedItems = totalElementsCount-queue.size();%0A%09%09%09double fractionCompleted = completedItems/(double) totalElementsCount;%0A%09%09%09double completedPercentage = fractionCompleted*100;%0A%09%09%09String progressDisplay = MathUtil.round(completedPercentage, 1)+%22%25%22;%0A%09%09%09%0A%09%09%09logger.info(%22Multithreader progress: %7B%7D%22, progressDisplay);%0A%09%09%09lastProgressLogInstant = Instant.now();%0A%09%09%7D%0A%09%09
 %0A%09%09v

Add progress logging to MultithreaderQueue_Collection