I'm implementing an observer pattern that the subject notifies observers and I knew it has a issue as bellow.
- Issue : iterator for notify() can be invalid, when container for observers like std::vector, std::list is modified on being notified.
But as I think, in single thread single process environment, invalid iterator issue never be happen except in as bellow situation.
- situation 1 : some observers modify observer container when it notified.
- situation 2: loop for notify() modify observer container on being notified.
I know, situation 1,2 make iterator invalid, but I want to know concrete case.
Hope some advice. Thanks.
Aucun commentaire:
Enregistrer un commentaire