1
- #if compiler(>=6.1) && _runtime(_multithreaded) // @_expose and @_extern are only available in Swift 6.1+
2
-
3
1
import JavaScriptKit
4
2
import _CJavaScriptKit
5
3
import _CJavaScriptEventLoop
6
4
7
- import Synchronization
5
+ #if canImport(Synchronization)
6
+ import Synchronization
7
+ #endif
8
8
#if canImport(wasi_pthread)
9
9
import wasi_pthread
10
10
import WASILibc
@@ -471,7 +471,9 @@ public final class WebWorkerTaskExecutor: TaskExecutor {
471
471
/// Enqueue a job scheduled from a Web Worker thread to the main thread.
472
472
/// This function is called when a job is enqueued from a Web Worker thread.
473
473
@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+
474
475
@_expose ( wasm, " swjs_enqueue_main_job_from_worker " )
476
+ #endif
475
477
func _swjs_enqueue_main_job_from_worker( _ job: UnownedJob ) {
476
478
WebWorkerTaskExecutor . traceStatsIncrement ( \. receiveJobFromWorkerThread)
477
479
JavaScriptEventLoop . shared. enqueue ( ExecutorJob ( job) )
@@ -480,13 +482,13 @@ func _swjs_enqueue_main_job_from_worker(_ job: UnownedJob) {
480
482
/// Wake up the worker thread.
481
483
/// This function is called when a job is enqueued from the main thread to a worker thread.
482
484
@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+
483
486
@_expose ( wasm, " swjs_wake_worker_thread " )
487
+ #endif
484
488
func _swjs_wake_worker_thread( ) {
485
489
WebWorkerTaskExecutor . Worker. currentThread!. run ( )
486
490
}
487
491
488
- #endif
489
-
490
492
fileprivate func trace( _ message: String ) {
491
493
#if JAVASCRIPTKIT_TRACE
492
494
JSObject . global. process. stdout. write ( " [trace tid= \( swjs_get_worker_thread_id ( ) ) ] \( message) \n " )
0 commit comments