Skip to content

Commit

Permalink
Merge pull request #30 from stzn/update-example
Browse files Browse the repository at this point in the history
Exampleの更新
  • Loading branch information
stzn authored Jul 16, 2024
2 parents db3c628 + 279fb72 commit 85662ed
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Sources/Examples/IncrementalMigration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Dispatch
import ObjCLibrary

/// Example that backs an actor with a queue.
///
/// > Note: `DispatchSerialQueue`'s initializer was only made available in more recent OS versions.
@available(macOS 14.0, iOS 17.0, macCatalyst 17.0, tvOS 17.0, watchOS 10.0, *)
actor LandingSite {
private let queue = DispatchSerialQueue(label: "SerialQueue")

// this currently failed to build because of the @available usage, rdar://116684282
// nonisolated var unownedExecutor: UnownedSerialExecutor {
// queue.asUnownedSerialExecutor()
// }

func acceptTransport(_ transport: JPKJetPack) {
// this function will be running on queue
}
}

func exerciseIncrementalMigrationExamples() async {
print("Incremental Migration Examples")

if #available(macOS 14.0, iOS 17.0, macCatalyst 17.0, tvOS 17.0, watchOS 10.0, *) {
print(" - using an actor with a DispatchSerialQueue executor")
let site = LandingSite()

let transport = JPKJetPack()

await site.acceptTransport(transport)
await site.acceptTransport(transport)
await site.acceptTransport(transport)
}
}
1 change: 1 addition & 0 deletions Sources/Examples/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ let manualSerialQueue = DispatchQueue(label: "com.apple.SwiftMigrationGuide")
await exerciseGlobalExamples()
await exerciseBoundaryCrossingExamples()
await exerciseConformanceMismatchExamples()
await exerciseIncrementalMigrationExamples()

0 comments on commit 85662ed

Please sign in to comment.