Browse Source

ADD: add participant to a list on connect

main
Dominik Meyer 2 months ago
parent
commit
a0d174df08
Signed by: byterazor GPG Key ID: B4C312B600606B64
  1. 6
      include/EventManager/Manager.hpp
  2. 17
      src/EventManager/Manager.cpp

6
include/EventManager/Manager.hpp

@ -66,6 +66,12 @@
/// mutex to protect schedulingPlugins_
std::mutex mutexSchedulingParticipants_;
/// list of all participants connected
std::list<std::shared_ptr<EventManager::Participant>> particpants_;
/// mutex to protect participants_
std::mutex mutexParticipants_;
/*
* all private methods
*/

17
src/EventManager/Manager.cpp

@ -328,11 +328,28 @@
void EventManager::Manager::connect(std::shared_ptr<EventManager::Participant> participant)
{
std::lock_guard<std::mutex> guard(mutexParticipants_);
particpants_.push_back(participant);
participant->setManager(shared_from_this());
participant->init();
}
void EventManager::Manager::disconnect(std::shared_ptr<EventManager::Participant> participant)
{
disconnect(participant);
std::lock_guard<std::mutex> guard(mutexParticipants_);
std::list<std::shared_ptr<EventManager::Participant>>::iterator it;
it = std::find(particpants_.begin(), particpants_.end(),participant);
if (it != particpants_.end())
{
particpants_.erase(it);
}
participant->setManager(nullptr);
}

Loading…
Cancel
Save