| 440 | } |
| 441 | |
| 442 | void routing_manager_client::register_event(client_t _client, service_t _service, instance_t _instance, event_t _notifier, |
| 443 | const std::set<eventgroup_t>& _eventgroups, const event_type_e _type, |
| 444 | reliability_type_e _reliability, std::chrono::milliseconds _cycle, bool _change_resets_cycle, |
| 445 | bool _update_on_change, epsilon_change_func_t _epsilon_change_func, bool _is_provided) { |
| 446 | |
| 447 | bool is_cyclic(_cycle != std::chrono::milliseconds::zero()); |
| 448 | |
| 449 | const event_data_t registration = { |
| 450 | service_instance_t{_service, _instance}, _notifier, _type, _reliability, _is_provided, is_cyclic, _eventgroups}; |
| 451 | bool is_first(false); |
| 452 | { |
| 453 | std::scoped_lock its_lock(pending_event_registrations_mutex_); |
| 454 | is_first = !pending_event_registrations_.contains(registration); |
| 455 | if (is_first) { |
| 456 | pending_event_registrations_.insert(registration); |
| 457 | } |
| 458 | bool insert = true; |
| 459 | if (is_first) { |
| 460 | for (auto iter = pending_event_registrations_.begin(); iter != pending_event_registrations_.end();) { |
| 461 | if (iter->service_instance_.service() == _service && iter->service_instance_.instance() == _instance |
| 462 | && iter->notifier_ == _notifier && iter->is_provided_ == _is_provided && iter->type_ == event_type_e::ET_EVENT |
| 463 | && _type == event_type_e::ET_SELECTIVE_EVENT) { |
| 464 | iter = pending_event_registrations_.erase(iter); |
| 465 | iter = pending_event_registrations_.insert(registration).first; |
| 466 | is_first = true; |
| 467 | insert = false; |
| 468 | break; |
| 469 | } else { |
| 470 | iter++; |
| 471 | } |
| 472 | } |
| 473 | if (insert) { |
| 474 | pending_event_registrations_.insert(registration); |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | if (_is_provided) { |
| 479 | std::scoped_lock its_lock{provider_mutex_}; |
| 480 | register_provider_event(_client, _service, _instance, _notifier, _eventgroups, _type, _reliability, _cycle, _change_resets_cycle, |
| 481 | _update_on_change, _epsilon_change_func, false, its_lock); |
| 482 | } else if (is_first) { |
| 483 | std::scoped_lock its_lock{consumer_mutex_}; |
| 484 | register_consumer_event(_client, _service, _instance, _notifier, _eventgroups, _type, _reliability, _cycle, _change_resets_cycle, |
| 485 | _update_on_change, _epsilon_change_func, false, its_lock); |
| 486 | } |
| 487 | if (state_machine_->state() == routing_client_state_e::ST_REGISTERED && is_first) { |
| 488 | send_register_event(get_client(), _service, _instance, _notifier, _eventgroups, _type, _reliability, _is_provided, is_cyclic); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | void routing_manager_client::unregister_event(client_t _client, service_t _service, instance_t _instance, event_t _notifier, |
| 493 | bool _is_provided) { |