// 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;
		queue.offer(ScheduledTask.allocate(() -> {

		}, expectedStartTimeNanos));

		final AtomicLong result = new AtomicLong(-1L);
		Thread thread = new Thread(() -> {
			try {
				final ScheduledTask task = queue.take();
				result.set(System.nanoTime());
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		});

		thread.start();
		try {
			thread.join();
		} catch (Exception e) {}

		Assert.assertTrue(result.get() >= expectedStartTimeNanos);
	}

	@Test
	public void testDelayWithEmptyQueue() {
		final ScheduledTaskQueue queue = new ScheduledTaskQueue(MAX_CAPACITY);
		final long expectedStartTimeNanos = System.nanoTime() + TimeUnit.SECONDS.toNanos(1L);

		final AtomicLong result = new AtomicLong(-1L);
		Thread thread = new Thread(() -> {
			try {
// 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;

		queue.offer(ScheduledTask.allocate(() -> {

		}, expectedStartTimeNanos));

		final AtomicLong result = new AtomicLong(-1L);
		Thread thread = new Thread(() -> {
			try {
				final ScheduledTask task = queue.take();
				result.set(System.nanoTime());
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		});

		thread.start();
		try {
			thread.join();
		} catch (Exception e) {}

		Assert.assertTrue(result.get() >= expectedStartTimeNanos);
	}

	@Test
	public void testDelayWithEmptyQueue() {
		final ScheduledTaskQueue queue = new ScheduledTaskQueue(MAX_CAPACITY);
		final long expectedStartTimeNanos = System.nanoTime() + TimeUnit.SECONDS.toNanos(1L);

		final AtomicLong result = new AtomicLong(-1L);
		Thread thread = new Thread(() -> {
			try {
				final ScheduledTask task = queue.take();