 		}
 	}
 	
-	// Run the next event. If nil is returned, no further events remain. If
-	func runNextTask() -> DebugContextTimer? {
+	func nextTask() -> (DebugContextThread, UInt64)? {
 		var lowestTime = UInt64.max
 		var selectedIndex = DebugContextThread.unspecified
 		

		if lowestTime == UInt64.max {
			return nil
		}
		currentThread = selectedIndex
		internalTime = lowestTime
		return queues[selectedIndex]?.popAndInvokeNext()
	}
}


		}
	}
	
	/// Performs all scheduled actions in a serial loop.
	///
	/// - parameter stoppingAfter: If nil, loop will continue until `stop` invoked or until no actions remain. If non-nil, loop will abort after an action matching Cancellable is completed.
	public func runScheduledTasks(untilTime: UInt64) {
		stopRequested = false
		currentThread = .unspecified
		while !stopRequested, let (threadIndex, time) = nextTask(), time <= untilTime {
			_ = runTask(threadIndex: threadIndex, time: time)
		}
		if stopRequested {
			queues = [:]
		}
	}
	
	/// Causes `runScheduledTasks` to exit as soon as possible, if it is running.
	public func stop() {
		stopRequested = true
