Skip to content

Commit f0bfc09

Browse files
committedJan 15, 2024
Update Executor/enqueue conformance to use ExecutorJob
1 parent a5b135d commit f0bfc09

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift

+8
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,17 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
130130
})
131131
}
132132

133+
#if compiler(>=5.9)
134+
public func enqueue(_ job: consuming ExecutorJob) {
135+
// NOTE: Converting a `ExecutorJob` to an ``UnownedJob`` and invoking
136+
// ``UnownedJob/runSynchronously(_:)` on it multiple times is undefined behavior.
137+
insertJobQueue(job: UnownedJob(job))
138+
}
139+
#else
133140
public func enqueue(_ job: UnownedJob) {
134141
insertJobQueue(job: job)
135142
}
143+
#endif
136144

137145
public func asUnownedSerialExecutor() -> UnownedSerialExecutor {
138146
return UnownedSerialExecutor(ordinary: self)

0 commit comments

Comments
 (0)