Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/swift/DispatchStubs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ _swift_dispatch_release(dispatch_object_t obj) {
dispatch_release(obj);
}

SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
extern "C" void
_swift_dispatch_retain(dispatch_object_t obj) {
dispatch_retain(obj);
}

// DISPATCH_RUNTIME_STDLIB_INTERFACE
// extern "C" dispatch_queue_t
// _swift_apply_current_root_queue() {
Expand Down
12 changes: 7 additions & 5 deletions src/swift/Wrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,20 @@ extension DispatchSource : DispatchSourceProcess,

internal class __DispatchData : DispatchObject {
internal let __wrapped:dispatch_data_t
internal let __owned:Bool

final internal override func wrapped() -> dispatch_object_t {
return unsafeBitCast(__wrapped, to: dispatch_object_t.self)
}

internal init(data:dispatch_data_t, owned:Bool) {
__wrapped = data
__owned = owned
if !owned {
_swift_dispatch_retain(unsafeBitCast(data, to: dispatch_object_t.self))
}
}

deinit {
if __owned {
_swift_dispatch_release(wrapped())
}
_swift_dispatch_release(wrapped())
}
}

Expand Down Expand Up @@ -335,3 +334,6 @@ internal enum _OSQoSClass : UInt32 {

@_silgen_name("_swift_dispatch_release")
internal func _swift_dispatch_release(_ obj: dispatch_object_t) -> Void

@_silgen_name("_swift_dispatch_retain")
internal func _swift_dispatch_retain(_ obj: dispatch_object_t) -> Void