| 87 | } |
| 88 | |
| 89 | void local_endpoint::start(uint32_t _lc_token) { |
| 90 | std::unique_lock lock{mutex_}; |
| 91 | peer_data_.lc_token_ = _lc_token; |
| 92 | is_started_ = true; |
| 93 | if (state_ == state_e::INIT) { |
| 94 | connect_unlock(); |
| 95 | } else if (state_ == state_e::CONNECTED) { |
| 96 | // Posting the actual start action here ensures that |
| 97 | // every public method can be called without re-entering any other callback. |
| 98 | boost::asio::post(io_, [this, weak_self = weak_from_this()] { |
| 99 | if (auto self = weak_self.lock(); self) { |
| 100 | std::unique_lock inner_lock{mutex_}; |
| 101 | // ensure that we weren't stopped in between |
| 102 | if (state_ != state_e::CONNECTED) { |
| 103 | VSOMEIP_INFO_P << "post: Not starting to process due to state: " << status_unlock(); |
| 104 | return; |
| 105 | } |
| 106 | if (!process(0, inner_lock)) { |
| 107 | escalate_internal(inner_lock); |
| 108 | return; |
| 109 | } |
| 110 | // only now we allow sending |
| 111 | send_unlock(); |
| 112 | } |
| 113 | }); |
| 114 | } else { |
| 115 | VSOMEIP_ERROR_P << "Unexpected state when trying to start: " << status_unlock(); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | void local_endpoint::stop(bool _due_to_error) { |
| 120 | std::unique_lock lock{mutex_}; |
no test coverage detected