Prior to this commit, when an actor was sent a message (from another actor or from the ASIO thread), it might get scheduled on the inject queue or the sending actor's scheduler thread depending on whether the context of the sending thread was a runtime scheduler thread or not. This was required to ensure that sending from the ASIO thread would add the actor to the inject queue. The same behavior was relied on during the runtime startup to ensure actors created before the scheduler threads were started were put on the inject queue. This made it hard to ensure that the cycle detector always ended up on the inject queue instead of the sending actor's scheduler thread. it was also less efficient than necessary for the majority of scenarios when an unscheduled actor might need to be scheduled due to a message send due to the extra branch.
This commit changes things to be more explicit.
The ASIO thread will now always add unscheduled actors to the inject queue. All message sends to the cycle detector will always add the cycle detector to the inject queue if it is unscheduled. All other message sends will always schedule unscheduled actors onto the sending actor's scheduler threadi (except for actor constructor messages which will keep using the old behavior). New functionality has been added and existing functionality has been modified to support this more explicit behavior.
New functionality has been added to send messages to actors and the add them to the inject queue if they are not scheduled. The existing functionality to send messages to actors has been modified to always add unscheduled actors to the sending actor's scheduler thread. The old behavior of relying on whether the context of the sending thread was a runtime scheduler thread or not is only retained for when actors are sent their constructors (and is only required during runtime startup) via pony_sendv_single.
Prior to this commit, when an actor was sent a message (from another actor or from the ASIO thread), it might get scheduled on the inject queue or the sending actor's scheduler thread depending on whether the context of the sending thread was a runtime scheduler thread or not. This was required to ensure that sending from the ASIO thread would add the actor to the inject queue. The same behavior was relied on during the runtime startup to ensure actors created before the scheduler threads were started were put on the inject queue. This made it hard to ensure that the cycle detector always ended up on the inject queue instead of the sending actor's scheduler thread. it was also less efficient than necessary for the majority of scenarios when an unscheduled actor might need to be scheduled due to a message send due to the extra branch.
This commit changes things to be more explicit.
The ASIO thread will now always add unscheduled actors to the inject queue. All message sends to the cycle detector will always add the cycle detector to the inject queue if it is unscheduled. All other message sends will always schedule unscheduled actors onto the sending actor's scheduler threadi (except for actor constructor messages which will keep using the old behavior). New functionality has been added and existing functionality has been modified to support this more explicit behavior.
New functionality has been added to send messages to actors and the add them to the inject queue if they are not scheduled. The existing functionality to send messages to actors has been modified to always add unscheduled actors to the sending actor's scheduler thread. The old behavior of relying on whether the context of the sending thread was a runtime scheduler thread or not is only retained for when actors are sent their constructors (and is only required during runtime startup) via
pony_sendv_single
.