[Haskell-cafe] Need help with very simple C++ FFI call

Carter Schonwald carter.schonwald at gmail.com
Tue Nov 19 17:15:24 UTC 2013


There's a flag you can pass to ghci for that thread local issue. I forget
what it is, but it should be in the manual.

On Tuesday, November 19, 2013, Thiago Padilha wrote:

> On Tue, Nov 19, 2013 at 1:50 PM, Yuras Shumovich <shumovichy at gmail.com<javascript:;>>
> wrote:
> >
> > Ok, then I don't see anything obviously wrong.
> >
> > I was embeding v8 into haskell project few months ago, and almost the
> > same code works for me.
> >
> > I don't have v8 installed right now, so I can't try your code at the
> > moment, but I see only one not trivial difference with my code. I'm
> > creating isolate manually, and you are using the default one. Check that
> > Isolate::GetCurrent() returns anything. I can imaging that your code is
> > running in unbound green thread, or it is bound to OS thread other then
> > the main one. v8 use thread local storage, that can be the issue.
>
> Yuras, you are correct now :)
>
> I've replaced the first line by these:
>
>      Isolate* isolate = Isolate::New();
>     // Sets this isolate as the entered one for the current thread
>     isolate->Enter();
>
> And the example worked as expected. Thanks for this very useful tip.
>
> I still dont understand why ghci is not using the default thread to
> run the binding, but from now on I will be more alert when binding to
> libraries that uses threads.
>
> Theres something else I also dont understood about FFI: When trying to
> debug the problem I've written many printf statements  but none of
> them showed on the screen, but now that the example is working I've
> notice that all printed text appears once I exit ghci. Why is that
> happening?
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org <javascript:;>
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131119/93d3ea54/attachment.html>


More information about the Haskell-Cafe mailing list