<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="">The compiler could rewrite this:</div><div class=""><br class=""></div><div class="">print(await dataModel.getNumberOfEntries())</div><div class=""><br class=""></div><div class="">actor func getNumberOfEntries() -> Int<div class="">{</div><div class=""> return theList.count</div><div class="">}</div></div><div class=""><br class=""></div><div class="">as this:</div><div class=""><br class=""></div><div class="">dataModel.getNumberOfEntries(_internalQueue) { count in</div><div class=""> print(count)</div><div class="">}<br class=""><br class="">actor func getNumberOfEntries(queue: DispatchQueue, handler: Int -> Void) -> Void<br class="">{</div><div class=""> _internalQueue.async {<br class=""> let count = theList.count</div><div class=""> queue.async {</div><div class=""> handler(count)</div><div class=""> }</div><div class=""> }<br class="">}</div><div class=""><br class=""></div><div class="">There is another problem that bothers me, if the function were to await on another actor (and therefore dispatch away from its _internalQueue), how would you guarantee that "only one message is processed by the actor at a time". You would need to somehow prevent the internal queue from processing other messages.</div><div class=""><br class=""></div><div class="">Thomas</div><br class=""><div><blockquote type="cite" class=""><div class="">On 18 Aug 2017, at 17:13, Johannes Weiß via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">GCD doesn't actually allow you to dispatch back to the original queue, so I find it unclear how you'd achieve that. IMHO the main reason is that conceptually at a given time you can be on more than one queue (nested q.sync{}/target queues). So which is 'the' current queue?</span></div></blockquote></div><br class=""></body></html>