ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.05k stars 372 forks source link

etl::send_message doesn't allow for non-virtual calls #820

Closed edobez closed 2 months ago

edobez commented 5 months ago

When using etl::send_message on a router, the call to on_receive goes through virtual calls instead of being directly dispatched. This is not occurring when the message is posted using etl::message_router::receive directly.

I verified this using the code from Message router example through Godbolt (link).

Using etl::send_message: image

Using etl::message_router::receive: image

Probably this is not a problem on itself, only that is not documented anywhere and the doc page states "The on_receive functions are not virtual" which can be misleading, considering that the send_message is also used in the examples.

jwellbelove commented 5 months ago

etl::send_message could be refactored as a template function, thereby resolving to a direct call for a concrete message_router derived object, or a virtual call for a base reference.

jwellbelove commented 2 months ago

Fixed 20.38.11