This is definitely the right forum for these types of questions.

Reading MSDN docs on Fibers, it seems that SwitchToFiber()ing will freeze
the currently executing fiber on the current thread, and jump the thread
over to the call stack of the another fiber and resume its execution, and
later SwitchToFiber()ing back will freeze the other thread's callstack
where it was going, and resume from the callstack of the first thread.

This kind of feature requires that one is able to capture function
callstacks and resume from them. Unfortunately it is not possible to
manipulate the callstack of a thread, even with upcoming pthreads, so this
is not natively possible, except by allocating a native pthread for each
fiber.

Emscripten does however have the Emterpreter feature, where Emscripten
includes a bytecode interpreter to the compiled output, which executes the
code. That would be able to implement fibers support. I'm not sure if that
would be of interest here though?

2017-05-16 5:05 GMT+03:00 Mark Sibly <[email protected]>:

> Hi,
>
> Is there any support planned for something like 'fibers' in WebAssembly?
>
> Basically, this is just super simple cooperative threading that allows you
> to do (a form of) async programming. The Windows API supports fibers via
> CreateFiber and SwitchToFiber (and that's about the whole API)  No other
> OS's do I think (although they apparently used to via 'contexts').
>
> The language I am writing that transpiles to c++ supports fibers thanks to
> the boost.coroutine package. This contains equivalent versions of
> CreateFiber and SwitchToFiber for a ton of OS's (written in ASM of course),
> including windows, linux, macos, android, ios. It works great and I don't
> actually even use the coroutine stuff.
>
> You can do some cool stuff on top of fibers - boost.coroutine does
> coroutines (generators?) in pure c++ on top of them, and there is even a
> proposal around for c# style async/await etc in c++ using fibers.
>
> I haven't had a whole lot of experience with this stuff, but I find fibers
> incredibly useful, super simple and think they would be a very cool
> addition to WASM. Especially, of course, for my needs so yes, there's a bit
> of self interest here...
>
> Dunno, this is probably not the right place to be mentioning it, but I
> just wondered if anyone knew whether something like this is happening?
>
> And if not here, where should I be asking questions like this?
>
> Bye!
> Mark
>
> --
> 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.

Reply via email to