Skip to content

Commit 6fbe084

Browse files
committed
Use correct type for setTimeout in JavaScriptEventLoop
1 parent 08a284e commit 6fbe084

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
1212
/// See also: https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide
1313
let queueMicrotask: @Sendable (@escaping () -> Void) -> Void
1414
/// A function that invokes a given closure after a specified number of milliseconds.
15-
let setTimeout: @Sendable (UInt64, @escaping () -> Void) -> Void
15+
let setTimeout: @Sendable (Double, @escaping () -> Void) -> Void
1616

1717
/// A mutable state to manage internal job queue
1818
/// Note that this should be guarded atomically when supporting multi-threaded environment.
1919
var queueState = QueueState()
2020

2121
private init(
2222
queueTask: @Sendable @escaping (@escaping () -> Void) -> Void,
23-
setTimeout: @Sendable @escaping (UInt64, @escaping () -> Void) -> Void
23+
setTimeout: @Sendable @escaping (Double, @escaping () -> Void) -> Void
2424
) {
2525
self.queueMicrotask = queueTask
2626
self.setTimeout = setTimeout
@@ -83,7 +83,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable {
8383

8484
private func enqueue(_ job: UnownedJob, withDelay nanoseconds: UInt64) {
8585
let milliseconds = nanoseconds / 1_000_000
86-
setTimeout(milliseconds, {
86+
setTimeout(Double(milliseconds), {
8787
job._runSynchronously(on: self.asUnownedSerialExecutor())
8888
})
8989
}

0 commit comments

Comments
 (0)