Skip to content

Commit aec76ce

Browse files
Revert debug changes in JavaScriptEventLoop
1 parent 91258e2 commit aec76ce

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift

+3-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import JavaScriptKit
22
import _CJavaScriptEventLoop
33
import _CJavaScriptKit
4-
import Synchronization
54

65
// NOTE: `@available` annotations are semantically wrong, but they make it easier to develop applications targeting WebAssembly in Xcode.
76

@@ -143,16 +142,16 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
143142

144143
typealias swift_task_enqueueMainExecutor_hook_Fn = @convention(thin) (UnownedJob, swift_task_enqueueMainExecutor_original) -> Void
145144
let swift_task_enqueueMainExecutor_hook_impl: swift_task_enqueueMainExecutor_hook_Fn = { job, original in
146-
assert(false)
147145
JavaScriptEventLoop.shared.unsafeEnqueue(job)
148146
}
149147
swift_task_enqueueMainExecutor_hook = unsafeBitCast(swift_task_enqueueMainExecutor_hook_impl, to: UnsafeMutableRawPointer?.self)
150148

151149
didInstallGlobalExecutor = true
152150
}
153151

154-
func enqueue(_ job: UnownedJob, withDelay nanoseconds: UInt64) {
155-
enqueue(withDelay: nanoseconds, job: {
152+
private func enqueue(_ job: UnownedJob, withDelay nanoseconds: UInt64) {
153+
let milliseconds = nanoseconds / 1_000_000
154+
setTimeout(Double(milliseconds), {
156155
#if compiler(>=5.9)
157156
job.runSynchronously(on: self.asUnownedSerialExecutor())
158157
#else
@@ -161,23 +160,6 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
161160
})
162161
}
163162

164-
func enqueue(withDelay nanoseconds: UInt64, job: @escaping () -> Void) {
165-
let milliseconds = nanoseconds / 1_000_000
166-
setTimeout(Double(milliseconds), job)
167-
}
168-
169-
func enqueue(
170-
withDelay seconds: Int64, _ nanoseconds: Int64,
171-
_ toleranceSec: Int64, _ toleranceNSec: Int64,
172-
_ clock: Int32, job: @escaping () -> Void
173-
) {
174-
var nowSec: Int64 = 0
175-
var nowNSec: Int64 = 0
176-
swift_get_time(&nowSec, &nowNSec, clock)
177-
let delayNanosec = (seconds - nowSec) * 1_000_000_000 + (nanoseconds - nowNSec)
178-
enqueue(withDelay: delayNanosec <= 0 ? 0 : UInt64(delayNanosec), job: job)
179-
}
180-
181163
private func unsafeEnqueue(_ job: UnownedJob) {
182164
insertJobQueue(job: job)
183165
}

0 commit comments

Comments
 (0)