<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><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 class=""><blockquote type="cite" class=""><div class="">On May 12, 2016, at 22:29, Zach Waldowski via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">


<title class=""></title>

<div class=""><div class="">dispatch_get_context, dispatch_set_context are not around simply in the absence of blocks. They're just as useful as the queue-specific data APIs as they have thread-specific storage.<br class=""></div></div></div></blockquote><div class=""><br class=""></div><div class="">dispatch_get_context and dispatch_set_context are per-object storage of a single word, there is no connection to threads.</div><div class=""><br class=""></div><div class="">there are many problems with this API including the lack of synchronization between getters and setters and ill-defined ownership semantics (e.g. a setter replacing an already set context leaks the previous value).</div><div class=""><br class=""></div><div class="">On queues this API has been subsumed by the getSpecific/setSpecific API which does not have these problems, for other classes we felt that its drawbacks and problems outweighed the benefits that it provided.</div><div class=""><br class=""></div><div class="">Daniel</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">
<div style="font-family:Arial;" class="">&nbsp;</div>
<div id="sig40804545" class=""><div class="signature">Zach Waldowski<br class=""></div>
<div class="signature"><a href="mailto:zach@waldowski.me" class="">zach@waldowski.me</a><br class=""></div>
</div>
<div class="">&nbsp;</div>
<div class="">&nbsp;</div>
<div class="">On Thu, May 12, 2016, at 08:50 PM, Pierre Habouzit via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div class=""><blockquote type="cite" class=""><div class="">On May 12, 2016, at 10:49 AM, Jose Cheyo Jimenez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div class=""><div style="font-family:SFMono-Regular;font-size:11px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:SFMono-Regular;font-size:11px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" class=""><blockquote type="cite" class=""><div class="">On May 11, 2016, at 7:09 AM, Matt Wright via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div class=""><blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class=""><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">On May 10, 2016, at 11:52 PM, Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* What is your evaluation of the proposal?<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">I'm generally in favor of a modernized API overlay like this (and I've written something like it myself, albeit much simpler), but I'm hoping this proposal can go through another round or two of discussion/bikeshedding/revision before approval.<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">(Small note: I'm really happy about the strong-typed-ness of the Source subclasses, e.g. how mergeData is only available for Add/Or.)<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">In no particular order, here are some things on which I'm unclear, or not-so-+1:<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">- synchronously()'s block parameter should be @noescape. Perhaps more arguably, it should have a generic return type and rethrows, like autoreleasepool now does.<br class=""></div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Both of these are present in the changes I have for this proposal. The former point is a mistake in my proposal text, the latter is an unfortunate oversight on my part in putting together the proposal document.</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">- The names asynchronously(execute:) and synchronously(execute:) don't seem to fit with any API guidelines I'm aware of. Did you consider including the verb in the method name? &nbsp;<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">We did. Of the number of names that we discussed, none of them were perfect. sync/async are common in other languages but don’t fit the general direction of the Swift 3 naming conventions. Using `dispatchAsynchronously` is an extremely long method name, even more so than `asynchronously`. `perform` does not capture the sync/async nature of the calls particularly well, compared to DispatchWorkItem where `perform` immediately executes the block.</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">(And I'm guessing that "func synchronously(work:...)" is meant to be "func synchronously(execute work:...)”?)<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Right.</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">As another bikeshed-item, I'd vote for "Data.init(withoutCopying:...)" rather than "(bytesNoCopy:...)", and perhaps whenDone() instead of notify().<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Here the init() functions closely mirror Data from Foundation, the Objective-C class is toll-free bridged to NSData and we desired a close match to the Foundation Swift API. `notify` is Dispatch-only API though, I’ll go think over that one.</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">- Are DispatchWorkItemFlags meant to overlay dispatch_block_flags? It would be nice to explicitly list these in the proposal.<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">The dispatch_block_* API is completely superseded by DispatchWorkItem in the proposal. DispatchWorkItemFlags is the equivalent to dispatch_block_flags.</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">- Are functions like dispatch_barrier_sync totally gone in favor of passing a .barrier flag? It would be nice to explicitly state this in the proposal.<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Yes, you can supply .barrier to either `synchronously` or `asynchronously`, or create a DispatchWorkItem as a barrier item. Where possible the multiple variants of a class (dispatch_async, dispatch_barrier_async, etc) are collapsed into a single method with default arguments.</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">- I echo Austin's concerns about subclassability. I think it would be dangerously misleading if the classes were subclassable from user code, even if it didn't work properly.<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Building at compile time will fail. So you wouldn’t get very far trying to use them, I plan to investigate adding `final` here (it’s only absent for technical reasons, as the classes originate from Objective-C).</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">- What of the APIs provided on Semaphore and Group objects? I'd like to see these before I vote for the proposal.<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">These would be transformed similarly, I will include them when updating the proposal.</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">class DispatchSemaphore : DispatchObject { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;init(value: Int)</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func wait(timeout: DispatchTime = default) -&gt; Int</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func wait(walltime timeout: DispatchWalltime) -&gt; Int</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func signal() -&gt; Int</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">}</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">class DispatchGroup : DispatchObject {</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;init() &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func wait(timeout: DispatchTime = default) -&gt; Int</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func wait(walltime timeout: DispatchWalltime) -&gt; Int</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func notify(queue: DispatchQueue, block: () -&gt; Void)</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func enter()</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func leave()</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">}</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class="">- What will dispatch_set_target_queue's replacement look like look like?<br class=""></blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">extension DispatchObject { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func setTargetQueue(queue: DispatchQueue?)</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">}</span></span><br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<blockquote style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;orphans:auto;text-align:start;text-indent:0px;text-transform:none;white-space:normal;widows:auto;word-spacing:0px;-webkit-text-stroke-width:0px;" type="cite" class=""><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class="">- What about dispatch_once?<br class=""></div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
<div style="font-family:Arial;" class=""><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Removed. Swift already has lazy initialisation at the language level, dispatch_once is neither needed nor safe in Swift.</span></span><br class=""></div>
</div>
</blockquote><div class="">&nbsp;</div>
<div class="">Hi Matt,&nbsp;<br class=""></div>
<div class="">&nbsp;</div>
<div class="">What other API would be removed ? Could the proposal be updated with the API that will not be reachable from the swift wrapper?<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Thank you.&nbsp;<br class=""></div>
</div>
</div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
</div>
<div class="">- dispatch_retain/dispatch_release() that are obviously useless in swift<br class=""></div>
<div class="">- dispatch_get_context/dispatch_set_context() and dispatch_set_finalizer_f() because it has no ownership semantics and were only there for ports where you had no blocks (as in closures)<br class=""></div>
<div class="">- dispatch_once() and dispatch_once_f() because global initializers do that job in swift<br class=""></div>
<div class="">- in general all _f variants, which would be really awkward to use from swift anyway<br class=""></div>
<div class="">- anything that was deprecated in previous releases (dispatch_debug, dispatch_debugv, dispatch_get_current_queue) as per usual swift import rules<br class=""></div>
<div class="">&nbsp;</div>
<div class="">&nbsp;</div>
<div class="">-Pierre<br class=""></div>
<div style="font-family:Arial;" class="">&nbsp;</div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</blockquote><div style="font-family:Arial;" class="">&nbsp;</div>
</div>

_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></body></html>