Did you mean something like this?

EmterpreterAsync.handle(...);
return something;


But the return value might not be available until the callback, e.g. to get 
a key input, so I need to set the return value in `resume`.



regards,
- Lu

On Saturday, April 11, 2015 at 5:07:37 AM UTC+8, Alon Zakai wrote:
>
> I think if you add a return in g - outside of the handle() call - it will 
> just be returned. It will however be returned both the first time when 
> called (and starting to unwind the stack) and the second time when 
> restarted (after reconstructing the stack). You could tell which of those 
> you are in using EmterpreterAsync.state. Might be nicer to add an API for 
> that.
>
> - Alon
>
>
> On Fri, Apr 10, 2015 at 3:47 AM, Lu Wang <[email protected] <javascript:>
> > wrote:
>
>> Hi all,
>>
>>    Is there a way to return something from an async function with 
>> emterpreter? For example:
>>
>> ///main.c
>> void f() {
>>   printf("%d\n", g());
>> }
>>
>> ///main.js
>> function g() {
>>   EmterpreterAsync.handle(function(resume) {
>>     setTimeout(function() {
>>       resume(return_value); // ???
>>     }, 1000);
>>   });
>> }
>>
>>
>>    I saw that `resume` already takes a few parameters, so maybe we cannot 
>> simply do so. Currently the closet way is to write the return value into 
>> some memory address, but it would be better if the return value can be 
>> passed directly to the C code.
>>
>>
>>   regards,
>>   - Lu
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "emscripten-discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to