|
From: Jon L. <jon...@gm...> - 2014-02-19 23:54:30
|
Hi Luigi,
Thanks for the reply. I was starting to fear that was the case. I quickly
tried your suggestion and seems to still give me errors. I started using a
mutex before calling QL which obviously fixes the problem.
Jonghee, you need to create a sessionId() method which returns a unique id
(?). Luigi, correct me if I'm wrong but put this in my code:
this uses c++11 or boost.
#include <thread>
#ifdef QL_ENABLE_SESSIONS
int QuantLib::sessionId(void)
{
return std::this_thread::get_id().hash();
}
#endif
Jon
On 19 February 2014 23:10, QL <qua...@gm...> wrote:
> hi luigi
>
> im jonghee lee
>
> i was rebulid quantlib and my project.
>
> quantlib building was success. however my project failed to building.
>
> error message was there is no define sessionid() function.
>
> may i define sessionid() ?
>
> i was try define it, i faild...
>
>
>
> Sent from my iPhone
>
> > On 19 Feb 2014, at 23:32, Luigi Ballabio <lui...@gm...>
> wrote:
> >
> > Hello,
> > in its default configuration, QuantLib is not thread-safe (there's
> > a number of global objects that you're probably writing to from
> > different threads and that can cause race conditions). Your program
> > might work ("might") if you make those globals thread-local; to do
> > this with VC++, edit <ql/userconfig.hpp>, uncomment the line
> > //# define QL_ENABLE_SESSIONS
> > towards the end so that the macro is defined, and recompile both
> > QuantLib and your program.
> >
> > Hope this helps,
> > Luigi
> >
> >
> >> On Wed, Feb 12, 2014 at 1:10 AM, jlee <jon...@gm...>
> wrote:
> >> Hi,
> >> I am trying to calculate fair swap rate and using swapvaluation.cpp
> from the
> >> Examples. If I call the fairRate() method several times in a loop it
> works
> >> fine. But when I call it using threads I get random errors. I don't
> think
> >> it's actually the fairRate() method but part of the creation of the Swap
> >> object.
> >>
> >> I have attached an example from my bigger program but it reproduces the
> >> error. It's in MSVC++ 2013 and when you start the program, it prompts
> you
> >> for the number of threads to use. Usually if you use 10 you'll get the
> >> error, definitely if you use 20 threads. If you use only 1 thread, it
> loops
> >> several times and no errors occur.
> >>
> >> Hope this helps as it took awhile to isolate but I've reached the limit
> of
> >> my technical skills in debugging it. If you need any more information
> let me
> >> know.
> >>
> >> ql_test.rar <
> http://quantlib.10058.n7.nabble.com/file/n14958/ql_test.rar>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> http://quantlib.10058.n7.nabble.com/multi-threaded-swapvaluation-cpp-tp14958.html
> >> Sent from the quantlib-dev mailing list archive at Nabble.com.
> >>
> >>
> ------------------------------------------------------------------------------
> >> Android apps run on BlackBerry 10
> >> Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
> >> Now with support for Jelly Bean, Bluetooth, Mapview and more.
> >> Get your Android app in front of a whole new audience. Start now.
> >>
> http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
> >> _______________________________________________
> >> QuantLib-dev mailing list
> >> Qua...@li...
> >> https://lists.sourceforge.net/lists/listinfo/quantlib-dev
> >
> >
> >
> > --
> > <https://implementingquantlib.blogspot.com>
> > <https://twitter.com/lballabio>
> >
> >
> ------------------------------------------------------------------------------
> > Managing the Performance of Cloud-Based Applications
> > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
> > Read the Whitepaper.
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
> > _______________________________________________
> > QuantLib-dev mailing list
> > Qua...@li...
> > https://lists.sourceforge.net/lists/listinfo/quantlib-dev
>
|