<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=""><div class="">Then isn’t the example functionally equivalent to:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp;&nbsp;<span style="color: #ba2da2" class="">func</span> doit() {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #703daa" class="">DispatchQueue</span>.<span style="color: #3e1e81" class="">global</span>().<span style="color: #3e1e81" class="">async</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">let</span> dataResource&nbsp; = <span style="text-decoration: underline" class="">loadWebResource</span>(<span style="color: #d12f1b" class="">"dataprofile.txt"</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">let</span> imageResource = <span style="text-decoration: underline" class="">loadWebResource</span>(<span style="color: #d12f1b" class="">"imagedata.dat"</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">let</span> imageTmp&nbsp; &nbsp; &nbsp; = <span style="text-decoration: underline" class="">decodeImage</span>(dataResource, imageResource)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">let</span> imageResult &nbsp; = <span style="text-decoration: underline" class="">dewarpAndCleanupImage</span>(imageTmp)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>DispatchQueue<span style="color: #000000" class="">.</span>main<span style="color: #000000" class="">.</span><span style="color: #3e1e81" class="">async</span><span style="color: #000000" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">self</span>.imageResult = imageResult</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; }</div></div><div class=""><br class=""></div><div class="">if all of the API were synchronous? Why wouldn’t we just exhort people to write synchronous API code and continue using libdispatch? What am I missing?</div><div class=""><br class=""></div><div class="">-Kenny</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 8, 2017, at 2:33 PM, David Hart &lt;<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div 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 8 Sep 2017, at 20:34, Kenny Leung 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=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi All.<div class=""><br class=""></div><div class="">A point of clarification in this example:</div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; word-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(36, 41, 46); font-variant-ligatures: normal; orphans: 2; widows: 2;" class=""><span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">loadWebResource</span>(<span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">_</span> <span class="pl-smi" style="box-sizing: border-box;">path</span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">String</span>) async <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">-&gt;</span> Resource
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">decodeImage</span>(<span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">_</span> <span class="pl-smi" style="box-sizing: border-box;">r1</span>: Resource, <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">_</span> <span class="pl-smi" style="box-sizing: border-box;">r2</span>: Resource) async <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">-&gt;</span> Image
<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">dewarpAndCleanupImage</span>(<span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">_</span> <span class="pl-smi" style="box-sizing: border-box;">i</span> : Image) async <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">-&gt;</span> Image

<span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(111, 66, 193);">processImageData1</span>() async <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">-&gt;</span> Image {
    <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">let</span> dataResource  <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">=</span> await <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">loadWebResource</span>(<span class="pl-s" style="box-sizing: border-box; color: rgb(3, 47, 98);"><span class="pl-pds" style="box-sizing: border-box;">"</span>dataprofile.txt<span class="pl-pds" style="box-sizing: border-box;">"</span></span>)
    <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">let</span> imageResource <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">=</span> await <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">loadWebResource</span>(<span class="pl-s" style="box-sizing: border-box; color: rgb(3, 47, 98);"><span class="pl-pds" style="box-sizing: border-box;">"</span>imagedata.dat<span class="pl-pds" style="box-sizing: border-box;">"</span></span>)
    <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">let</span> imageTmp      <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">=</span> await <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">decodeImage</span>(dataResource, imageResource)
    <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">let</span> imageResult   <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">=</span> await <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">dewarpAndCleanupImage</span>(imageTmp)
    <span class="pl-k" style="box-sizing: border-box; color: rgb(215, 58, 73);">return</span> imageResult
}</pre><div class=""><br class=""></div></div><div class="">Do these:</div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; word-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(36, 41, 46); font-variant-ligatures: normal; orphans: 2; widows: 2;" class="">await <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">loadWebResource</span>(<span class="pl-s" style="box-sizing: border-box; color: rgb(3, 47, 98);"><span class="pl-pds" style="box-sizing: border-box;">"</span>dataprofile.txt<span class="pl-pds" style="box-sizing: border-box;">"</span></span>)</pre><div class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; word-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; color: rgb(36, 41, 46); font-variant-ligatures: normal; orphans: 2; widows: 2;" class="">await <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 92, 197);">loadWebResource</span>(<span class="pl-s" style="box-sizing: border-box; color: rgb(3, 47, 98);"><span class="pl-pds" style="box-sizing: border-box;">"</span>imagedata.dat<span class="pl-pds" style="box-sizing: border-box;">"</span></span>)</pre><div class=""><br class=""></div></div></div><div class="">happen in in parallel?</div></div></div></blockquote><div class=""><br class=""></div><div class="">They don’t happen in parallel.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">If so, how can I make the second one wait on the first one? If not, how can I make them go in parallel?</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">-Kenny</div><div class=""><br class=""></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=""></div></div></blockquote></div><br class=""></body></html>