Skip to content

Commit

Permalink
BugFix: mutability flag is now changed in to_immutable helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
eao197 committed Feb 11, 2021
1 parent 5acbe30 commit 73b0d1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dev/so_5/mhood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ typename std::enable_if< !is_signal<M>::value, mhood_t< immutable_msg< M > > >::
to_immutable( mhood_t< mutable_msg<M> > msg )
{
message_ref_t ref{ msg.make_reference() };
change_message_mutability( ref, message_mutability_t::immutable_message );

return { ref };
}

Expand Down
10 changes: 10 additions & 0 deletions dev/test/so_5/mutable_msg/mutable_to_immutable/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ private :

void on_hello_mut( mhood_t< so_5::mutable_msg< hello > > cmd )
{
ensure(
so_5::message_mutability_t::mutable_message ==
message_mutability( *cmd ),
"mutable message is expected" );

std::cout << "sobj: " << cmd->m_content << std::endl;

m_received_ptr = cmd.get();
Expand All @@ -47,6 +52,11 @@ private :

void on_hello_imm( mhood_t< hello > cmd )
{
ensure(
so_5::message_mutability_t::immutable_message ==
message_mutability( *cmd ),
"immutable message is expected" );

std::cout << "sobj: " << cmd->m_content << std::endl;

ensure( m_received_ptr == cmd.get(), "expect the same message" );
Expand Down

0 comments on commit 73b0d1b

Please sign in to comment.