-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Swift 5.10 permit the creation of actors with custom executors. A very common use case is actors backed with a DispatchQueue
. This is useful when wrapping lower-level APIs, such as FSEventStream
s or any queue-backed Core Foundation functionality. For those case, you can define an actor wrapping the state and be sure to be called back in the executor queue.
Swift 6 introduces the assumeIsolated(_:)
function that permits to jump synchronously to the actor's critical section; However that functionality is not backported and therefore you need to use "unsafe bitcasting" for systems running in Swift 5 runtimes. The bitcasting sadly produces a warning every time the bitcast is used. For cases such a File System monitor that will produce an exorbitant amount of warnings. The only way to remove those warnings is setting SWIFT_UNEXPECTED_EXECUTOR_LOG_LEVEL=0
.
We have discussed this in the Swift forums.