Restructed async load function
Solves #21440
@sbc100 @tlively I have restructured function in a way the promise is implemented at the top and callbacks are implemented at the base of the promise. For asyncify I can add a handle sleep call but we can use a flag instead.
I have run the test case and verified that the added function is creating no test failures. I am getting the following error while running tests on my local:
error: undefined symbol: saveSetjmp (referenced by root reference (e.g. compiled C/C++ code))
warning: To disable errors for undefined symbols use -sERROR_ON_UNDEFINED_SYMBOLS=0
warning: _saveSetjmp may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: testSetjmp (referenced by root reference (e.g. compiled C/C++ code))
warning: _testSetjmp may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
Could you help me with your valuable feedback on the overall code as well the test failures.
Taking a step back, can you describe your high-level goal here? I would have expected to see this PR define a new function called something like emscripten_async_load_script_promise that contains all the implementation logic, then redefine the existing callback-based emscripten_async_load_script in terms of that new function. In contrast, this PR seems to just change the implementation of the existing function to use a promise.
I tried to change the original function in the promise -> callbacks and asyncify format but after the feedback, I have introduced a new function implementing the promise flavour of the api and reconstructed the original function aorund the promise version with backward compatibility with callbacks. I was working on resolving the test failures since some time now. I would appreciate your feedback on my fundamental appproach in the latest commit @tlively @sbc100 @kripken
@sbc100 Could you review my pull request and suggest me with your valuable feedback