-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from stzn/update-example
Exampleの更新
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters