Message Order in dart isolates

Issue

If you use actors in Scala you don’t know if the messages arrive in order that you send them, does isolates in dart enshure that its messages gets received in the order you send them?

Solution

Interesting question. I don’t remember seeing it anywhere in the specification (but I might be wrong, and it might follow from some other parts of the spec), but in general, messages in Dart are always said to be enqueued, which also means that they are ordered.

From looking to the VM, it appears to be the case. Actually, there are two queues — “normal” messages and out of band (OOB) messages. The OOB messages are always prioritized over the normal ones, but they are currently only used to implement the mirrors API, so this should be no concern. There is no notion of priority (other than the normal/OOB distinction). In general, I think that the answer is yes, you receive messages in the same order as they were sent.

From time to time, Dart people talk about using message passing between isolates over the network (so that one isolate lives on one computer, another isolate lives on another computer and they communiacate transparently) — once this is implemented, it will make a great sense to ask this question again (and I hope the answer will remain the same).

Answered By – Ladicek

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.