Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class InputArchive {
- ...
- template <typename T>
- void process ( T && t ) {
- emscripten_yield();
- // deserialize ...
- }
- template <typename T>
- emscripten_coroutine async( T && t ) {
- // create type-erasure proxy that holds T
- return emscripten_coroutine_create( &coro_func, &proxy );
- }
- static void coro_func( void * arg ) {
- // cast arg to proxy
- proxy.process(); // proxy holds T argument, dispatch it to InputArchive::process
- }
- };
- void deserialize() {
- Document doc;
- auto coroutine = archive.async( doc );
- while( emscripten_coroutine_next( coroutine ) != 0 ) {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement