         return EventLoopFuture<T>(eventLoop: self, checkForPossibleDeadlock: false, result: result)
     }
     
-    func scheduleTask<T>(in: TimeAmount, _ task: @escaping () throws-> (T)) -> Scheduled<T> {
+    public func scheduleTask<T>(in: TimeAmount, _ task: @escaping () throws-> (T)) -> Scheduled<T> {
         let promise: EventLoopPromise<T> = newPromise()
         promise.fail(error: EventLoopError.unsupportedOperation)
         return Scheduled(promise: promise, cancellationTask: {

    // We're not really running a loop here. Tasks aren't run until run() is called,
    // at which point we run everything that's been submitted. Anything newly submitted
    // either gets on that train if it's still moving or
    func execute(task: @escaping () -> ()) {
        queue.sync {
            if isRunning && tasks.isEmpty {
                task()


import Dispatch

public class EmbeddedEventLoop : EventLoop {

    let queue = DispatchQueue(label: "embeddedEventLoopQueue", qos: .utility)
    public var inEventLoop: Bool {
        return true
    }
    var isRunning: Bool = false

    // Would be better to have this as a Queue
