[swift-users] [swift-dev] New Swift Snapshots Available!

Michael Ferenduros mike.ferenduros at gmail.com
Mon Aug 29 04:24:06 CDT 2016


> On 24 Aug 2016, at 12:38, Chris Bailey via swift-users <swift-users at swift.org> wrote:
> 
> If you haven't spotted it, the new snapshots include Dispatch on Linux for the first time - please test it out as there may well be number of issues to shake out, especially with the new Swift 3 API. 

A couple more DispatchSource issues - I’m getting a crash (on all platforms) if a source deallocs before the cancellation handler has been called, which seems to be a known issue.

To get around it on Darwin, I was taking an unmanaged retained ref to the source and releasing it in the cancellation handler. But it turns out that on Linux,
    let s: DispatchSourceRead = […]
    Unmanaged.passRetained(s)
crashes llvm. Giving the typechecker a hint
    Umanaged<DispatchSourceRead>(s)
tells me that type 'DispatchSourceRead' does not conform to protocol ‘AnyObject’ which seems weird. Is it still class-based on Linux, or something different?

I ended up doing this
    var rs: DispatchSourceRead? = rsource
    var ws: DispatchSourceWrite? = wsource
    rsource.setCancelHandler { _ = rs?.handle; rs = nil }   //Access a property to shut the bloody compiler up,
    wsource.setCancelHandler { _ = ws?.handle; ws = nil }   //and to ensure the var isn't optimised away.
so all the above is moot, but I thought I should report it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160829/82cf45b3/attachment.html>


More information about the swift-users mailing list