Created
August 15, 2025 09:27
-
-
Save jacobsapps/31f5213f9bd7ee0ee72205d36df3b98a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/// Form task creation flags for use with the createAsyncTask builtins. | |
@available(SwiftStdlib 5.1, *) | |
@_alwaysEmitIntoClient | |
func taskCreateFlags( | |
priority: TaskPriority?, isChildTask: Bool, copyTaskLocals: Bool, | |
inheritContext: Bool, enqueueJob: Bool, | |
addPendingGroupTaskUnconditionally: Bool, | |
isDiscardingTask: Bool, | |
isSynchronousStart: Bool | |
) -> Int { | |
var bits = 0 | |
bits |= (bits & ~0xFF) | Int(priority?.rawValue ?? 0) | |
if isChildTask { | |
bits |= 1 << 8 | |
} | |
if copyTaskLocals { | |
bits |= 1 << 10 | |
} | |
if inheritContext { | |
bits |= 1 << 11 | |
} | |
if enqueueJob { | |
bits |= 1 << 12 | |
} | |
if addPendingGroupTaskUnconditionally { | |
bits |= 1 << 13 | |
} | |
if isDiscardingTask { | |
bits |= 1 << 14 | |
} | |
// 15 is used by 'IsTaskFunctionConsumed' | |
if isSynchronousStart { | |
bits |= 1 << 16 | |
} | |
return bits | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment