<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 3, 2016, at 10:11 AM, Quinn The Eskimo! via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">On 3 May 2016, at 18:02, Tyler Fleming Cloutier &lt;<a href="mailto:cloutiertyler@aol.com" class="">cloutiertyler@aol.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">My motivation for doing something like that is that I would prefer not to make the listen function mutating inside my struct.<br class=""></blockquote><br class="">I recommend that you be explicit about your source references. &nbsp;If this struct owns the source, have it maintain a strong reference to the source. &nbsp;In your case it seems that `fd` is an attribute of the struct, so you could create the source when the struct is initialised with `fd`. &nbsp;You don’t have to configure or resume it at that point, just create it.<br class=""><br class="">Share and Enjoy<br class=""></div></div></blockquote><div><br class=""></div><div>Yep that would work, however, it’s a little trickier if I want to have a protocol extension:</div><div><br class=""></div><div><a href="https://github.com/TheArtOfEngineering/Edge/blob/master/Sources/IOStream.swift" class="">https://github.com/TheArtOfEngineering/Edge/blob/master/Sources/IOStream.swift</a></div><div><br class=""></div><div>I could just have a readonly var which just references the underlying dispatch_source_t though!</div><div><br class=""></div><div>Thanks for the help!</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="">--<br class="">Quinn "The Eskimo!" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;<a href="http://www.apple.com/developer/" class="">http://www.apple.com/developer/</a>&gt;<br class="">Apple Developer Relations, Developer Technical Support, Core OS/Hardware<br class=""><br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></div></blockquote></div><br class=""></body></html>