// Path: core/src/main/java/org/mini2Dx/miniscript/core/threadpool/ScheduledTask.java
// public class ScheduledTask implements Comparable<ScheduledTask> {
// 	private static final ReadWriteArrayQueue<ScheduledTask> POOL = new ReadWriteArrayQueue<>();
// 
// 	private ScheduledTaskFuture future;
// 
// 	private Runnable runnable;
// 	private long scheduledStartTimeNanos;
// 
// 	private long repeatInterval;
// 	private TimeUnit repeatUnit;
// 
// 	private boolean disposed = false;
// 
// 	public void dispose() {
// 		if(disposed) {
// 			return;
// 		}
// 
// 		disposed = true;
// 
// 		runnable = null;
// 		scheduledStartTimeNanos = 0L;
// 
// 		repeatUnit = null;
// 		repeatInterval = 0L;
// 
// 		future = null;
// 
// 		POOL.add(this);
// 	}
// 
// 	public static ScheduledTask allocate(Runnable runnable, long scheduledStartTimeNanos) {
// 		ScheduledTask task = POOL.poll();
// 		if(task == null) {
// 			task = new ScheduledTask();
// 		}
// 		task.disposed = false;
// 		task.runnable = runnable;
// 		task.scheduledStartTimeNanos = scheduledStartTimeNanos;
// 		return task;
// 	}
// 
// 	public static ScheduledTask allocate(Runnable runnable, long scheduledStartTimeNanos, long repeatInterval, TimeUnit repeatUnit) {
// 		ScheduledTask task = POOL.poll();
// 		if(task == null) {
// 			task = new ScheduledTask();
// 		}
// 		task.disposed = false;
// 		task.runnable = runnable;
// 		task.scheduledStartTimeNanos = scheduledStartTimeNanos;
// 		task.repeatUnit = repeatUnit;
// 		task.repeatInterval = repeatInterval;
// 		return task;
// 	}
// 
// 	public Runnable getRunnable() {
// 		return runnable;
// 	}
// 
// 	public long getScheduledStartTimeNanos() {
// 		return scheduledStartTimeNanos;
// 	}
// 
// 	public boolean isRepeating() {
// 		return repeatUnit != null;
// 	}
// 
// 	public long getRepeatInterval() {
// 		return repeatInterval;
// 	}
// 
// 	public TimeUnit getRepeatUnit() {
// 		return repeatUnit;
// 	}
// 
// 	@Override
// 	public int compareTo(ScheduledTask o) {
// 		return Long.compare(scheduledStartTimeNanos, o.scheduledStartTimeNanos);
// 	}
// 
// 	public ScheduledTaskFuture getFuture() {
// 		return future;
// 	}
// 
// 	public void setFuture(ScheduledTaskFuture future) {
// 		this.future = future;
// 	}
// }


import org.junit.Assert;
import org.junit.Test;
import org.mini2Dx.miniscript.core.threadpool.ScheduledTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
/**
 * Copyright 2021 Viridian Software Ltd.
 */
package org.mini2Dx.miniscript.core.util;



public class ScheduledTaskQueueTest {
	private static final int MAX_CAPACITY = 5;

	@Test
	public void testDelay() {
		final ScheduledTaskQueue queue = new ScheduledTaskQueue(MAX_CAPACITY);
		final long expectedStartTimeNanos = System.nanoTime() + TimeUnit.SECONDS.toNanos(2L);
// Path: core/src/main/java/org/mini2Dx/miniscript/core/threadpool/ScheduledTask.java
// public class ScheduledTask implements Comparable<ScheduledTask> {
// 	private static final ReadWriteArrayQueue<ScheduledTask> POOL = new ReadWriteArrayQueue<>();
// 
// 	private ScheduledTaskFuture future;
// 
// 	private Runnable runnable;
// 	private long scheduledStartTimeNanos;
// 
// 	private long repeatInterval;
// 	private TimeUnit repeatUnit;
// 
// 	private boolean disposed = false;
// 
// 	public void dispose() {
// 		if(disposed) {
// 			return;
// 		}
// 
// 		disposed = true;
// 
// 		runnable = null;
// 		scheduledStartTimeNanos = 0L;
// 
// 		repeatUnit = null;
// 		repeatInterval = 0L;
// 
// 		future = null;
// 
// 		POOL.add(this);
// 	}
// 
// 	public static ScheduledTask allocate(Runnable runnable, long scheduledStartTimeNanos) {
// 		ScheduledTask task = POOL.poll();
// 		if(task == null) {
// 			task = new ScheduledTask();
// 		}
// 		task.disposed = false;
// 		task.runnable = runnable;
// 		task.scheduledStartTimeNanos = scheduledStartTimeNanos;
// 		return task;
// 	}
// 
// 	public static ScheduledTask allocate(Runnable runnable, long scheduledStartTimeNanos, long repeatInterval, TimeUnit repeatUnit) {
// 		ScheduledTask task = POOL.poll();
// 		if(task == null) {
// 			task = new ScheduledTask();
// 		}
// 		task.disposed = false;
// 		task.runnable = runnable;
// 		task.scheduledStartTimeNanos = scheduledStartTimeNanos;
// 		task.repeatUnit = repeatUnit;
// 		task.repeatInterval = repeatInterval;
// 		return task;
// 	}
// 
// 	public Runnable getRunnable() {
// 		return runnable;
// 	}
// 
// 	public long getScheduledStartTimeNanos() {
// 		return scheduledStartTimeNanos;
// 	}
// 
// 	public boolean isRepeating() {
// 		return repeatUnit != null;
// 	}
// 
// 	public long getRepeatInterval() {
// 		return repeatInterval;
// 	}
// 
// 	public TimeUnit getRepeatUnit() {
// 		return repeatUnit;
// 	}
// 
// 	@Override
// 	public int compareTo(ScheduledTask o) {
// 		return Long.compare(scheduledStartTimeNanos, o.scheduledStartTimeNanos);
// 	}
// 
// 	public ScheduledTaskFuture getFuture() {
// 		return future;
// 	}
// 
// 	public void setFuture(ScheduledTaskFuture future) {
// 		this.future = future;
// 	}
// }


// Path: core/src/test/java/org/mini2Dx/miniscript/core/util/ScheduledTaskQueueTest.java
import org.junit.Assert;
import org.junit.Test;
import org.mini2Dx.miniscript.core.threadpool.ScheduledTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;

/**
 * Copyright 2021 Viridian Software Ltd.
 */
package org.mini2Dx.miniscript.core.util;



public class ScheduledTaskQueueTest {
	private static final int MAX_CAPACITY = 5;

	@Test
	public void testDelay() {
		final ScheduledTaskQueue queue = new ScheduledTaskQueue(MAX_CAPACITY);
		final long expectedStartTimeNanos = System.nanoTime() + TimeUnit.SECONDS.toNanos(2L);
		queue.offer(ScheduledTask.allocate(() -> {