ADD: add participant to a list on connect
This commit is contained in:
parent
e7b1eeeaa1
commit
a0d174df08
@ -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
|
||||
*/
|
||||
|
@ -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…
Reference in New Issue
Block a user