The following implementation always prints true
if the actor method doIt
is called async from the main thread:
actor CustomActor: SerialExecutor {
let queue = DispatchQueue(label: "SerialExecutorQueue")
nonisolated func enqueue(_ job: consuming ExecutorJob) {
let job = UnownedJob(job)
queue.sync {
job.runSynchronously(on: unownedExecutor)
}
}
nonisolated var unownedExecutor: UnownedSerialExecutor {
asUnownedSerialExecutor()
}
func doIt() {
print(Thread.isMainThread)
}
}
Is my implementation wrong, or is this some kind of runtime bug?