samedi 15 juillet 2017

How can completed futures be automatically erased from std::vector

In the following exampl, mEventExecutors is a std::vector<std::future<void>>. I would like to be able to remove the futures from the vector, as they complete. Can this be done?

void RaiseEvent(EventID messageID)
{
    mEventExecutors.push_back(std::move(std::async([=]{
            auto eventObject = mEventListeners.find(messageID);
            if (eventObject != mEventListeners.end())
            {
                for (auto listener : eventObject->second)
                {
                    listener();
                }
            }
        })
    ));
}

Aucun commentaire:

Enregistrer un commentaire