<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div id="sig40804545"><div class="signature">Zach Waldowski<br></div>
<div class="signature"><a href="mailto:zach@waldowski.me">zach@waldowski.me</a><br></div>
</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>On Thu, May 12, 2016, at 08:50 PM, Pierre Habouzit via swift-evolution wrote:<br></div>
<blockquote type="cite"><div><blockquote type="cite"><div>On May 12, 2016, at 10:49 AM, Jose Cheyo Jimenez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<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;">&nbsp;</div>
<div style="font-family:Arial;">&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;"><blockquote type="cite"><div>On May 11, 2016, at 7:09 AM, Matt Wright via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div style="font-family:Arial;">&nbsp;</div>
<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"><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">On May 10, 2016, at 11:52 PM, Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* What is your evaluation of the proposal?<br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">(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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">In no particular order, here are some things on which I'm unclear, or not-so-+1:<br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">- synchronously()'s block parameter should be @noescape. Perhaps more arguably, it should have a generic return type and rethrows, like autoreleasepool now does.<br></div>
</blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&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">- 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></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&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">(And I'm guessing that "func synchronously(work:...)" is meant to be "func synchronously(execute work:...)”?)<br></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">Right.</span></span><br></div>
<div style="font-family:Arial;">&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">As another bikeshed-item, I'd vote for "Data.init(withoutCopying:...)" rather than "(bytesNoCopy:...)", and perhaps whenDone() instead of notify().<br></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&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">- Are DispatchWorkItemFlags meant to overlay dispatch_block_flags? It would be nice to explicitly list these in the proposal.<br></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&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">- 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></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&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">- 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></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&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">- What of the APIs provided on Semaphore and Group objects? I'd like to see these before I vote for the proposal.<br></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;init(value: Int)</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func signal() -&gt; Int</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">}</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">class DispatchGroup : DispatchObject {</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func enter()</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func leave()</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">}</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">&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">- What will dispatch_set_target_queue's replacement look like look like?<br></blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">&nbsp;func setTargetQueue(queue: DispatchQueue?)</span></span><br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><span class="font" style="font-family:Helvetica"><span class="size" style="font-size:12px">}</span></span><br></div>
<div style="font-family:Arial;">&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"><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;">- What about dispatch_once?<br></div>
</blockquote><div style="font-family:Arial;">&nbsp;</div>
<div style="font-family:Arial;"><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></div>
</div>
</blockquote><div>&nbsp;</div>
<div>Hi Matt,&nbsp;<br></div>
<div>&nbsp;</div>
<div>What other API would be removed ? Could the proposal be updated with the API that will not be reachable from the swift wrapper?<br></div>
<div>&nbsp;</div>
<div>Thank you.&nbsp;<br></div>
</div>
</div>
</blockquote><div style="font-family:Arial;">&nbsp;</div>
</div>
<div>- dispatch_retain/dispatch_release() that are obviously useless in swift<br></div>
<div>- 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></div>
<div>- dispatch_once() and dispatch_once_f() because global initializers do that job in swift<br></div>
<div>- in general all _f variants, which would be really awkward to use from swift anyway<br></div>
<div>- anything that was deprecated in previous releases (dispatch_debug, dispatch_debugv, dispatch_get_current_queue) as per usual swift import rules<br></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>-Pierre<br></div>
<div style="font-family:Arial;">&nbsp;</div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div style="font-family:Arial;">&nbsp;</div>
</body>
</html>