1.1 --- a/lemon/bits/alteration_notifier.h Mon Jul 16 16:21:40 2018 +0200
1.2 +++ b/lemon/bits/alteration_notifier.h Wed Oct 17 19:14:07 2018 +0200
1.3 @@ -2,7 +2,7 @@
1.4 *
1.5 * This file is a part of LEMON, a generic C++ optimization library.
1.6 *
1.7 - * Copyright (C) 2003-2009
1.8 + * Copyright (C) 2003-2013
1.9 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 *
1.12 @@ -23,6 +23,7 @@
1.13 #include <list>
1.14
1.15 #include <lemon/core.h>
1.16 +#include <lemon/bits/lock.h>
1.17
1.18 //\ingroup graphbits
1.19 //\file
1.20 @@ -251,7 +252,7 @@
1.21
1.22 typedef std::list<ObserverBase*> Observers;
1.23 Observers _observers;
1.24 -
1.25 + lemon::bits::Lock _lock;
1.26
1.27 public:
1.28
1.29 @@ -332,14 +333,18 @@
1.30 protected:
1.31
1.32 void attach(ObserverBase& observer) {
1.33 + _lock.lock();
1.34 observer._index = _observers.insert(_observers.begin(), &observer);
1.35 observer._notifier = this;
1.36 + _lock.unlock();
1.37 }
1.38
1.39 void detach(ObserverBase& observer) {
1.40 + _lock.lock();
1.41 _observers.erase(observer._index);
1.42 observer._index = _observers.end();
1.43 observer._notifier = 0;
1.44 + _lock.unlock();
1.45 }
1.46
1.47 public: