Currently not. It would require a very different code generation approach than we currently have.
In theory something similar could be done using generators, in very recent versions of firefox and chrome. But even with the help of generators, this is not easy to do, and it is not clear how it would affect performance - likely very adversely. One similar thing you can do is manage your own code using c++11 lambdas. You could write a little system that continues to run the current function once a callback triggers that. - Alon On Sun, Mar 16, 2014 at 1:43 AM, Joel Croteau <[email protected]> wrote: > I would like to have a function that makes an async call, and returns > control to the browser during the call, then resumes once the async call is > complete. However, I would like this to appear to the calling code to be a > synchronous call. So for instance, I could do something like this: > > struct FileInfo > { > void* buffer; > unsigned size; > }; > > FileInfo loadUrl(const char* url) > { > FileInfo info; > emscripten_async_wget2_data(url, "GET", "", &info, false, onload, > onerror, onprogress); > emscripten_pause(); // Blocks until emscripten_resume() is called > return info; > } > > void onerror(void* ptr, int code, const char* desc) > { > // Handle not found, etc. > } > > void onprogress(void* ptr, int loaded, int total) > { > // Update progress bar > } > > void onload(void* ptr, void* buffer, unsigned size) > { > static_cast<FileInfo*>(ptr)->buffer = buffer; > static_cast<FileInfo*>(ptr)->size = size; > > emscripten_resume(); // Now loadUrl resumes and returns FileInfo. > } > > Is there any way to do this? > > -- > 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. > -- 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.
