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. <span></span><br><br>On Tuesday, November 19, 2013, Thiago Padilha  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, Nov 19, 2013 at 1:50 PM, Yuras Shumovich <<a href="javascript:;" onclick="_e(event, 'cvml', 'shumovichy@gmail.com')">shumovichy@gmail.com</a>> wrote:<br>
><br>
> Ok, then I don't see anything obviously wrong.<br>
><br>
> I was embeding v8 into haskell project few months ago, and almost the<br>
> same code works for me.<br>
><br>
> I don't have v8 installed right now, so I can't try your code at the<br>
> moment, but I see only one not trivial difference with my code. I'm<br>
> creating isolate manually, and you are using the default one. Check that<br>
> Isolate::GetCurrent() returns anything. I can imaging that your code is<br>
> running in unbound green thread, or it is bound to OS thread other then<br>
> the main one. v8 use thread local storage, that can be the issue.<br>
<br>
Yuras, you are correct now :)<br>
<br>
I've replaced the first line by these:<br>
<br>
     Isolate* isolate = Isolate::New();<br>
    // Sets this isolate as the entered one for the current thread<br>
    isolate->Enter();<br>
<br>
And the example worked as expected. Thanks for this very useful tip.<br>
<br>
I still dont understand why ghci is not using the default thread to<br>
run the binding, but from now on I will be more alert when binding to<br>
libraries that uses threads.<br>
<br>
Theres something else I also dont understood about FFI: When trying to<br>
debug the problem I've written many printf statements  but none of<br>
them showed on the screen, but now that the example is working I've<br>
notice that all printed text appears once I exit ghci. Why is that<br>
happening?<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'Haskell-Cafe@haskell.org')">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote>