Skip to content

Commit

Permalink
Merge pull request #599 from compnerd/block-flags
Browse files Browse the repository at this point in the history
swift: remove Windows special case in `Block.swift`
  • Loading branch information
compnerd authored Oct 1, 2022
2 parents 4bf826d + 68acc3f commit 469c8ec
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/swift/Block.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,15 @@ public class DispatchWorkItem {
internal var _block: _DispatchBlock

public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> ()) {
#if os(Windows)
#if arch(arm64) || arch(x86_64)
let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
#else
let flags = dispatch_block_flags_t(UInt(flags.rawValue))
#endif
#else
let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
#endif
let flags: dispatch_block_flags_t = dispatch_block_flags_t(CUnsignedLong(flags.rawValue))
_block = dispatch_block_create_with_qos_class(flags,
qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block)
}

// Used by DispatchQueue.synchronously<T> to provide a path through
// dispatch_block_t, as we know the lifetime of the block in question.
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
#if os(Windows)
#if arch(arm64) || arch(x86_64)
let flags = dispatch_block_flags_t(UInt32(flags.rawValue))
#else
let flags = dispatch_block_flags_t(UInt(flags.rawValue))
#endif
#else
let flags: dispatch_block_flags_t = numericCast(flags.rawValue)
#endif
let flags: dispatch_block_flags_t = dispatch_block_flags_t(CUnsignedLong(flags.rawValue))
_block = _swift_dispatch_block_create_noescape(flags, noescapeBlock)
}

Expand Down

0 comments on commit 469c8ec

Please sign in to comment.