import Foundation import Vapor import NIOCore import Clairvoyant final class EventLoopScheduler { private let backgroundGroup: EventLoopGroup init() { backgroundGroup = MultiThreadedEventLoopGroup(numberOfThreads: 2) } func next() -> EventLoop { backgroundGroup.next() } func provider() -> NIOEventLoopGroupProvider { return .shared(backgroundGroup) } func shutdown() { backgroundGroup.shutdownGracefully { _ in } } } extension EventLoopScheduler: AsyncScheduler { func schedule(asyncJob: @escaping @Sendable () async throws -> Void) { _ = backgroundGroup.any().makeFutureWithTask(asyncJob) } }