1- #if compiler(>=6.1) && _runtime(_multithreaded) // @_expose and @_extern are only available in Swift 6.1+
2-
31import JavaScriptKit
42import _CJavaScriptKit
53import _CJavaScriptEventLoop
64
7- import Synchronization
5+ #if canImport(Synchronization)
6+ import Synchronization
7+ #endif
88#if canImport(wasi_pthread)
99 import wasi_pthread
1010 import WASILibc
@@ -471,7 +471,9 @@ public final class WebWorkerTaskExecutor: TaskExecutor {
471471/// Enqueue a job scheduled from a Web Worker thread to the main thread.
472472/// This function is called when a job is enqueued from a Web Worker thread.
473473@available ( macOS 15 . 0 , iOS 18 . 0 , watchOS 11 . 0 , tvOS 18 . 0 , visionOS 2 . 0 , * )
474+ #if compiler(>=6.1) // @_expose and @_extern are only available in Swift 6.1+
474475@_expose ( wasm, " swjs_enqueue_main_job_from_worker " )
476+ #endif
475477func _swjs_enqueue_main_job_from_worker( _ job: UnownedJob ) {
476478 WebWorkerTaskExecutor . traceStatsIncrement ( \. receiveJobFromWorkerThread)
477479 JavaScriptEventLoop . shared. enqueue ( ExecutorJob ( job) )
@@ -480,13 +482,13 @@ func _swjs_enqueue_main_job_from_worker(_ job: UnownedJob) {
480482/// Wake up the worker thread.
481483/// This function is called when a job is enqueued from the main thread to a worker thread.
482484@available ( macOS 15 . 0 , iOS 18 . 0 , watchOS 11 . 0 , tvOS 18 . 0 , visionOS 2 . 0 , * )
485+ #if compiler(>=6.1) // @_expose and @_extern are only available in Swift 6.1+
483486@_expose ( wasm, " swjs_wake_worker_thread " )
487+ #endif
484488func _swjs_wake_worker_thread( ) {
485489 WebWorkerTaskExecutor . Worker. currentThread!. run ( )
486490}
487491
488- #endif
489-
490492fileprivate func trace( _ message: String ) {
491493#if JAVASCRIPTKIT_TRACE
492494 JSObject . global. process. stdout. write ( " [trace tid= \( swjs_get_worker_thread_id ( ) ) ] \( message) \n " )
0 commit comments