diff -r cd72eae05bdf -r 3c00344f49c9 lemon/bits/alteration_notifier.h --- a/lemon/bits/alteration_notifier.h Mon Jul 16 16:21:40 2018 +0200 +++ b/lemon/bits/alteration_notifier.h Wed Oct 17 19:14:07 2018 +0200 @@ -2,7 +2,7 @@ * * This file is a part of LEMON, a generic C++ optimization library. * - * Copyright (C) 2003-2009 + * Copyright (C) 2003-2013 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * @@ -23,6 +23,7 @@ #include #include +#include //\ingroup graphbits //\file @@ -251,7 +252,7 @@ typedef std::list Observers; Observers _observers; - + lemon::bits::Lock _lock; public: @@ -332,14 +333,18 @@ protected: void attach(ObserverBase& observer) { + _lock.lock(); observer._index = _observers.insert(_observers.begin(), &observer); observer._notifier = this; + _lock.unlock(); } void detach(ObserverBase& observer) { + _lock.lock(); _observers.erase(observer._index); observer._index = _observers.end(); observer._notifier = 0; + _lock.unlock(); } public: