> On May 3, 2016, at 10:11 AM, Quinn The Eskimo! via swift-users > <swift-users@swift.org> wrote: > > > On 3 May 2016, at 18:02, Tyler Fleming Cloutier <cloutierty...@aol.com> wrote: > >> My motivation for doing something like that is that I would prefer not to >> make the listen function mutating inside my struct. > > I recommend that you be explicit about your source references. If this > struct owns the source, have it maintain a strong reference to the source. > 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`. You don’t have > to configure or resume it at that point, just create it. > > Share and Enjoy
Yep that would work, however, it’s a little trickier if I want to have a protocol extension: https://github.com/TheArtOfEngineering/Edge/blob/master/Sources/IOStream.swift <https://github.com/TheArtOfEngineering/Edge/blob/master/Sources/IOStream.swift> I could just have a readonly var which just references the underlying dispatch_source_t though! Thanks for the help! > -- > Quinn "The Eskimo!" <http://www.apple.com/developer/> > Apple Developer Relations, Developer Technical Support, Core OS/Hardware > > > _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users