hello,
you'll need to modify the file ql/Patterns/singleton.hpp to support TLS.
In case you're working with VC++, check out this article:
http://www.codeproject.com/threads/tls.asp
Also, make that *no* data is shared at all between threads.
BTW, in case you are still getting crashes it's always good to put trace
statements in the code and putting sleep() statements at strategic
points. Multi-threaded debugging is not for the faint-hearted ;-)
Regards,
Ashish
zheng wang wrote:
> Ashish,
> do you have a list of classes we need to convert in QuantLib or in the
> driver code?
> Thanks.
> Jim
>
> */Ashish Kulkarni /* wrote:
>
> You will have to make the Singleton class template thread-safe. The
> simplest way is to put the data in Thread-Local Storage. Using a mutex
> is not really ideal, as you'll run into performance issues very quickly.
>
> Also, check that you are not writing to shared STL containers in
> multiple threads, as the STL itself is not guarenteed to be thread-safe.
>
> zheng wang wrote:
>> we would like to run Swapvaluation.cpp in a multithreaded environment;
>> we modified the code by wrapping all the functionality in main() of the
>> aforementioned file into a new function abc() and created two threads in
>> main() to call abc(). It always crashes. I wonder if we did something
>> wrong or QuantLib is not thread-safe at all. Your help would be greatly
>> appreciated.
>> Thanks.
>
Greetings!
ICICI Infotech
is now 3i Infotech.
The e-mail addresses
of the company's employees have been changed to <existing name>@3i-infotech.com.
You are requested to take note of this new e-mail ID and make use of the
same in future
"This e-mail
message may contain confidential, proprietary or legally privileged information.
It should not be used by anyone who is not the original intended recipient.
If you have erroneously received this message, please delete it immediately
and notify the sender. The recipient acknowledges that 3i Infotech or
its subsidiaries and associated companies, (collectively "3i Infotech"),
are unable to exercise control or ensure or guarantee the integrity of/over
the contents of the information contained in e-mail transmissions and
further acknowledges that any views expressed in this message are those
of the individual sender and no binding nature of the message shall be
implied or assumed unless the sender does so expressly with due authority
of 3i Infotech. Before opening any attachments please check them for viruses
and defects."
|