Commits

Arnold Schwaighofer committed d454c936f76
Add _withUnsafeGuaranteedRef to Unmanaged This is an internal method that will go away in the future. Get the value of the unmanaged referenced as a managed reference without consuming an unbalanced retain of it and pass it to the closure. Asserts that there is some other reference ('the owning reference') to the unmanaged reference that guarantees the lifetime of the unmanaged reference for the duration of the '_withUnsafeGuaranteedRef' call. var owningReference = Instance() ... withExtendedLifetime(owningReference) { let u = Unmanaged.passUnretained(owningReference) for i in 0 ..< 100 { // Assert that the reference in 'u' is kept alive by another storage // location or value that holds the same reference. u._withUnsafeGuaranteedRef { $0.doSomething() } } } // owningReference's lifetime (reference count > 0) is guaranteed // for this scope. rdar://25129935