Re: Looping dependencies
Posted by
Ferdinando M. Ametrano-3 on
Feb 07, 2012; 3:03pm
URL: http://quantlib.414.s1.nabble.com/Looping-dependencies-tp13460p13461.html
Hi LucaOn Sun, Feb 5, 2012 at 9:26 PM, Luca Billi <
[hidden email]> wrote:
> I noticed that the current implementation of LazyObjects generates
> infinite recursions
> in the case the dependency hierarchy among Observer/Observable objects
> contains loops.
>
> A suggestion to break the infinite recursion is to replace the update()
> method as follows:
> [...]good catch, even if on the 1.2.0 release branch it was already fixed as in the following
inline void LazyObject::update() {
// forwards notifications only the first time
if (calculated_) {
// set to false early, otherways non-lazy observers would be
// served obsolete data because of calculated_ being still true
calculated_ = false;
// observers don't expect notifications from frozen objects
if (!frozen_)
notifyObservers();
}
}
I've added your "prevent infinite recursion" comment too
ciao -- Nando
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev