Squashed commit of the following:

commit 007b56d03513887636b84fc246e57d6c4f8b777e
Author: John Wellbelove <github@wellbelove.co.uk>
Date:   Tue Feb 2 18:09:51 2021 +0000

    Squashed commit of the following:

    commit 6107c4538be149137209d85e5f41031291bc7150
    Author: John Wellbelove <github@wellbelove.co.uk>
    Date:   Tue Feb 2 12:15:31 2021 +0000

        Added move constructor and move assignment to etl::shared_message

    commit c9a5716012db9b614ea67660ebf64dcb790ce571
    Author: John Wellbelove <github@wellbelove.co.uk>
    Date:   Sun Jan 31 12:36:29 2021 +0000

        Squashed commit of the following:

        commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975
        Author: John Wellbelove <github@wellbelove.co.uk>
        Date:   Sun Jan 31 12:34:49 2021 +0000

            Squashed commit of the following:

            commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97
            Author: John Wellbelove <github@wellbelove.co.uk>
            Date:   Sun Jan 31 12:32:35 2021 +0000

                Fixed rollover error for etl::queue_spsc_atomic

                Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator.
                Updated QueuedMessageRouter example

commit e5f4eb6fb38c337c82fcc250f17a8f21eb788975
Author: John Wellbelove <github@wellbelove.co.uk>
Date:   Sun Jan 31 12:34:49 2021 +0000

    Squashed commit of the following:

    commit 23c5f1d3f9b13ff9e46ce3de96aefeb655d5ed97
    Author: John Wellbelove <github@wellbelove.co.uk>
    Date:   Sun Jan 31 12:32:35 2021 +0000

        Fixed rollover error for etl::queue_spsc_atomic

        Added 'required_alignment' parameter to 'allocate' for etl::imemeory_block_allocator.
        Updated QueuedMessageRouter example
This commit is contained in:
John Wellbelove 2021-02-02 18:13:29 +00:00
parent c9a5716012
commit ce8385ff24
6 changed files with 58 additions and 4 deletions

View File

@ -85,6 +85,17 @@ namespace etl
p_rcmessage->get_reference_counter().increment_reference_count();
}
#if ETL_CPP11_SUPPORTED
//*************************************************************************
/// Move constructor
//*************************************************************************
shared_message(etl::shared_message&& other)
: p_rcmessage(etl::move(other.p_rcmessage))
{
other.p_rcmessage = ETL_NULLPTR;
}
#endif
//*************************************************************************
/// Copy assignment operator
//*************************************************************************
@ -106,13 +117,37 @@ namespace etl
return *this;
}
#if ETL_CPP11_SUPPORTED
//*************************************************************************
/// Move assignment operator
//*************************************************************************
shared_message& operator =(etl::shared_message&& other)
{
if (&other != this)
{
// Deal with the current message.
if (p_rcmessage->get_reference_counter().decrement_reference_count() == 0U)
{
p_rcmessage->release();
}
// Move over the new one.
p_rcmessage = etl::move(other.p_rcmessage);
other.p_rcmessage = ETL_NULLPTR;
}
return *this;
}
#endif
//*************************************************************************
/// Destructor
/// Returns the message back to the pool it it is the last copy.
//*************************************************************************
~shared_message()
{
if (p_rcmessage->get_reference_counter().decrement_reference_count() == 0U)
if ((p_rcmessage != ETL_NULLPTR) &&
(p_rcmessage->get_reference_counter().decrement_reference_count() == 0U))
{
p_rcmessage->release();
}

View File

@ -39,7 +39,7 @@ SOFTWARE.
#define ETL_VERSION_MAJOR 19
#define ETL_VERSION_MINOR 5
#define ETL_VERSION_PATCH 2
#define ETL_VERSION_PATCH 3
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)

View File

@ -1,6 +1,6 @@
{
"name": "ETL Embedded Template Library",
"version": "19.5.2",
"version": "19.5.3",
"author s": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library ETL
version=19.5.2
version=19.5.3
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

View File

@ -1,3 +1,7 @@
===============================================================================
19.5.3
Added move constructor and move assignment operator to etl::shared_message.
===============================================================================
19.5.2
Fixed rollover error for etl::queue_spsc_atomic

View File

@ -179,6 +179,21 @@ namespace
}
};
//*************************************************************************
TEST(test_move_constructor)
{
etl::shared_message sm1(std::move(etl::shared_message(message_pool, Message1(1))));
CHECK_EQUAL(1, sm1.get_reference_count());
}
//*************************************************************************
TEST(test_move_assignemnt)
{
etl::shared_message sm2 = etl::shared_message(message_pool, Message1(2));
sm2 = std::move(etl::shared_message(message_pool, Message1(3)));
CHECK_EQUAL(1, sm2.get_reference_count());
}
//*************************************************************************
TEST(test_send_to_routers)
{