\section{Message Priorities}

By default, all messages have the same priority and actors ignore priority flags.
Actors that should evaluate priorities must be spawned using the \lstinline^priority_aware^ flag.
This flag causes the actor to use a priority-aware mailbox implementation.
It is not possible to change this implementation dynamically at runtime.

\begin{lstlisting}
using a_atom = atom_constant<atom("a")>;
using b_atom = atom_constant<atom("b")>;

behavior testee(event_based_actor* self) {
  // send 'b' with normal priority
  self->send(self, b_atom::value);
  // send 'a' with high priority
  self->send(message_priority::high, self, a_atom::value);
  // terminate after receiving a 'b'
  return {
    [=](b_atom) {
      aout(self) << "received 'b' => quit" << endl;
      self->quit();
    },
    [=](a_atom) {
      aout(self) << "received 'a'" << endl;
    },
  };
}

int main() {
  // will print "received 'b' => quit"
  spawn(testee);
  await_all_actors_done();
  // will print "received 'a'" and then "received 'b' => quit"
  spawn<priority_aware>(testee);
  await_all_actors_done();
  shutdown();
}
\end{lstlisting}
