Added non-member etl::send_message for etl::shared_message

This commit is contained in:
John Wellbelove 2022-06-25 12:04:43 +01:00
parent b77c7753d3
commit a074b42b91
3 changed files with 13 additions and 4 deletions

View File

@ -414,7 +414,7 @@ namespace etl
/// Send a message to a bus.
//***************************************************************************
static inline void send_message(etl::imessage_bus& bus,
const etl::imessage& message)
const etl::imessage& message)
{
bus.receive(message);
}
@ -423,8 +423,8 @@ namespace etl
/// Send a message to a bus.
//***************************************************************************
static inline void send_message(etl::imessage_bus& bus,
etl::message_router_id_t id,
const etl::imessage& message)
etl::message_router_id_t id,
const etl::imessage& message)
{
bus.receive(id, message);
}

View File

@ -319,6 +319,15 @@ namespace etl
destination.receive(message);
}
//***************************************************************************
/// Send a shared message to a router.
//***************************************************************************
static inline void send_message(etl::imessage_router& destination,
etl::shared_message message)
{
destination.receive(message);
}
//*************************************************************************************************
// For C++17 and above.
//*************************************************************************************************

View File

@ -230,7 +230,7 @@ namespace
bus.receive(sm2);
bus.receive(sm1);
bus.receive(sm3);
bus.receive(sm4); // sm4 is a copy of sm1
etl::send_message(bus, sm4); // sm4 is a copy of sm1. Use non-member function.
bus.receive(RouterId2, sm1); // Only send sm1 to Router2
CHECK(sm1.is_valid());