ADD: add participant to a list on connect

This commit is contained in:
Dominik Meyer 2021-08-16 20:20:01 +02:00
parent e7b1eeeaa1
commit a0d174df08
No known key found for this signature in database
GPG Key ID: B4C312B600606B64
2 changed files with 23 additions and 0 deletions

View File

@ -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
*/

View File

@ -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);
}