MailboxImpl::~MailboxImpl()
{
- clear();
+ clear(false);
set_receiver(nullptr);
}
/** @brief Removes all communication activities from a mailbox
*/
-void MailboxImpl::clear()
+void MailboxImpl::clear( bool do_post )
{
// CommImpl::cancel() will remove the comm from the mailbox..
for (auto comm : done_comm_queue_) {
comm->cancel();
comm->set_state(State::FAILED);
- comm->post();
+ if(do_post)
+ comm->post();
}
done_comm_queue_.clear();
if (comm->get_state() == State::WAITING && not comm->is_detached()) {
comm->cancel();
comm->set_state(State::FAILED);
- comm->post();
+ if(do_post)
+ comm->post();
} else
comm_queue_.pop_back();
}