void GraphListener::shutdown() { std::lock_guard<std::mutex> shutdown_lock(shutdown_mutex_); if (!is_shutdown_.exchange(true)) { if (is_started_) { interrupt_(&interrupt_guard_condition_); listener_thread_.join(); } rcl_ret_t ret = rcl_guard_condition_fini(&interrupt_guard_condition_); if (RCL_RET_OK != ret) { throw_from_rcl_error(ret, "failed to finalize interrupt guard condition"); } if (shutdown_guard_condition_) { rclcpp::utilities::release_sigint_guard_condition(&wait_set_); shutdown_guard_condition_ = nullptr; } if (is_started_) { ret = rcl_wait_set_fini(&wait_set_); if (RCL_RET_OK != ret) { throw_from_rcl_error(ret, "failed to finalize wait set"); } } } }
void rclcpp::utilities::release_sigint_guard_condition(rcl_wait_set_t * waitset) { std::lock_guard<std::mutex> lock(g_sigint_guard_cond_handles_mutex); auto kv = g_sigint_guard_cond_handles.find(waitset); if (kv != g_sigint_guard_cond_handles.end()) { if (rcl_guard_condition_fini(&kv->second) != RCL_RET_OK) { // *INDENT-OFF* (prevent uncrustify from making unnecessary indents here) throw std::runtime_error(std::string( "Failed to destroy sigint guard condition: ") + rcl_get_error_string_safe()); // *INDENT-ON* } g_sigint_guard_cond_handles.erase(kv); } else { // *INDENT-OFF* (prevent uncrustify from making unnecessary indents here) throw std::runtime_error(std::string( "Tried to release sigint guard condition for nonexistent waitset")); // *INDENT-ON* } }