Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
// See: https://github.com/swiftlang/swift/pull/80266
// See: https://forums.swift.org/t/pitch-2-custom-main-and-global-executors/78437

import _Concurrency
@_spi(ExperimentalCustomExecutors) import _Concurrency
import _CJavaScriptKit

#if compiler(>=6.3)

// MARK: - MainExecutor Implementation
// MainExecutor is used by the main actor to execute tasks on the main thread
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *)
@_spi(ExperimentalCustomExecutors)
extension JavaScriptEventLoop: MainExecutor {
public func run() throws {
// This method is called from `swift_task_asyncMainDrainQueueImpl`.
Expand All @@ -27,6 +28,7 @@ extension JavaScriptEventLoop: MainExecutor {
extension JavaScriptEventLoop: TaskExecutor {}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *)
@_spi(ExperimentalCustomExecutors)
extension JavaScriptEventLoop: SchedulingExecutor {
public func enqueue<C: Clock>(
_ job: consuming ExecutorJob,
Expand Down Expand Up @@ -65,6 +67,7 @@ extension JavaScriptEventLoop: SchedulingExecutor {

// MARK: - ExecutorFactory Implementation
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *)
@_spi(ExperimentalCustomExecutors)
extension JavaScriptEventLoop: ExecutorFactory {
// Forward all operations to the current thread's JavaScriptEventLoop instance
final class CurrentThread: TaskExecutor, SchedulingExecutor, MainExecutor, SerialExecutor {
Expand Down
2 changes: 1 addition & 1 deletion Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JavaScriptKit
import _Concurrency
@_spi(ExperimentalCustomExecutors) import _Concurrency
import _CJavaScriptEventLoop
import _CJavaScriptKit

Expand Down