<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="">The issue of a lack of ordering is one that actually comes up a lot in Swift, and we don’t have a good answer for it in general. That might be something we want to take a deeper look at in the Swift 5 timeframe (at least to talk about options). It would help more than just concurrency…<div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon<br class=""><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 18, 2017, at 8:51 PM, Shams Imam 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=""><div dir="ltr" class=""><br class=""><div class="gmail_quote"><div dir="ltr" class=""><p style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;font-variant-ligatures:normal;margin-top:0px" class="">Disclaimer: this was work done during my graduate study. It was presented in front of an audience that included Gul Agha who appreciated the work.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;font-variant-ligatures:normal" class="">The Actor model is great concurrency model to build on top of thanks to its data isolation and asynchronous message processing properties. However, lack of guarantees to control the order in which messages are processed by an actor makes implementing synchronization and coordination patterns difficult in the Actor model. Solutions to support such order in processing constraints may require the actor to buffer messages and resend the messages to itself until the message is processed. The resulting code is a petri-dish of code that intertwines both algorithmic logic and synchronization constraints.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;font-variant-ligatures:normal" class="">I would encourage you to look into the Selector model which is an extension of the Actor model that allows an actor to have multiple mailboxes. These mailboxes can be enabled/disabled to control which message is processed next by the selector (in many ways this is similar to a select operation among multiple channels in Communicating Sequential Processes style programs). Enabling/disabling does not affect which messages are accepted at a mailbox. </p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;font-variant-ligatures:normal" class="">In essence, an actor is a selector with a single mailbox which is always enabled. Selectors simplify writing of synchronization and coordination patterns using actors such as:<br class=""></p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;font-variant-ligatures:normal" class="">a) 'synchronous' request-reply,<br style="box-sizing:border-box" class="">b) join patterns in streaming applications,<br style="box-sizing:border-box" class="">c) supporting priorities in message processing,<br style="box-sizing:border-box" class="">d) variants of reader-writer concurrency, and<br style="box-sizing:border-box" class="">e) producer-consumer with bounded buffer.</p><div style="box-sizing: border-box; margin-top: 0px; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; font-variant-ligatures: normal; margin-bottom: 0px;" class=""><br class=""></div><div style="box-sizing: border-box; margin-top: 0px; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; font-variant-ligatures: normal; margin-bottom: 0px;" class="">Relevant links:<br style="box-sizing:border-box" class=""><a href="http://dl.acm.org/citation.cfm?id=2687360" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none" target="_blank" class="">http://dl.acm.org/citation.<wbr class="">cfm?id=2687360</a><br style="box-sizing:border-box" class="">Detailed description: <a href="https://shamsimam.github.io/papers/2014-agere-selector.pdf" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none" target="_blank" class="">https://<wbr class="">shamsimam.github.io/papers/<wbr class="">2014-agere-selector.pdf</a><br style="box-sizing:border-box" class="">Slides: <a href="https://shamsimam.github.io/papers/2014-agere-selector-slides.pdf" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none" target="_blank" class="">https://shamsimam.<wbr class="">github.io/papers/2014-agere-<wbr class="">selector-slides.pdf</a></div></div>
</div><br class=""></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>