Open Joannis opened 5 months ago
Thanks for the issue about this as we chatter earlier -- I'll investigate
This is executing as a task executor, so it must pass the self as task executor, not some arbitrary other object as serial executor:
This currently does:
//@available(macOS 15.0, *)
//extension EventLoop {
// @inlinable
// public func enqueue(_ job: consuming ExecutorJob) {
// let unownedJob = UnownedJob(job)
// self.execute {
// unownedJob.runSynchronously(on: self.asUnownedSerialExecutor())
// }
// }
//}
but it should:
func enqueue(_ job: consuming ExecutorJob) {
// eventLoop.enqueue(job)
let unownedJob = UnownedJob(job)
print("Job = \(unownedJob)")
self.eventLoop.execute {
unownedJob.runSynchronously(on: self.asUnownedTaskExecutor())
}
}
this works correctly, but we should diagnose better.
I'll investigate this more and follow up with improving docs and diagnostics
I just thought about this and it is going to make it almost impossible to implement both serial and task executor on a single type right? The protocol requirement for enqueue is exactly the same so how do we know if we need to pass self as an unowned serial or task executor?
Description
I've created a task executor based on a SwiftNIO EventLoop, and spawned tasks to a discarding task group for handling new clients connecting to my TCP server. Once I attach the executor, the example crashes.
Reproduction
Stack dump
Expected behavior
Task runs on the EventLoop
Environment
Apple Swift version 5.11-dev (LLVM 0c7051c13ba8526, Swift 192d275b78109ff) Target: arm64-apple-macosx14.0
Additional information
No response