11.07.2015 Views

Beyond Simple Monte-Carlo: Parallel Computing with QuantLib

Beyond Simple Monte-Carlo: Parallel Computing with QuantLib

Beyond Simple Monte-Carlo: Parallel Computing with QuantLib

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Multi-Threading: Observer-Pattern◮ The observer pattern itself can be solved using the thread-safeboost::signals2 library.◮ Problem remains, an observer must be unregistered from allobservables before the destructor is called.◮ Solution:◮ <strong>QuantLib</strong> enforces that all observers are instantiated as boostshared pointers.◮ The preprocessor directiveBOOST SP ENABLE DEBUG HOOKS provides a hook toevery destructor call of a shared object.◮ if the shared object is an observer then use the thread-safeversion of Observer::unregisterWithAll to detach the observerfrom all observables.◮ Advantage: this solution is backward compatible, e.g. testsuite can now run multi-threaded.Klaus Spanderen<strong>Beyond</strong> <strong>Simple</strong> <strong>Monte</strong>-<strong>Carlo</strong>: <strong>Parallel</strong> <strong>Computing</strong> <strong>with</strong> <strong>QuantLib</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!