#71 thread-safe session handling using tss

open
nobody
None
5
2012-10-19
2012-10-19
Riccardo Ghetta
No

QuantLib default session handling is thread safe only if you allocate all sessions beforehand, otherwise adding/removing a session id changes the map object potentially corrupting other thread iterators.
This patch uses boost::thread_specific_ptr to have a per-thread session id. Since the variable used is thread-private and inherently linked to the thread, no sessionId() method is needed.
The patch is enabled by defining QL_ENABLE_SESSIONS_TSS in config.hpp
Without the define QuantLib uses the old code.

Discussion

  • thread-safe sessions patch

     
    Attachments