Fibers, what for?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 12 21:33:08 PDT 2016


On 06/12/2016 07:19 PM, Patric Dexheimer wrote:
> On Monday, 13 June 2016 at 00:57:11 UTC, Alex Parrill wrote:
>> Also note that Vibe.d, the largest fiber-based framework D has to
>> offer, is capable of running several coroutines in parallel on
>> multiple threads, meaning you must use the same level of
>> synchronization as if you were using threads.
>
> Vibe.d framework share the same fibers between threads?
> Or each thread have his own fibers?
> I was trying this(shared fibers) but it didnt work.

D fibers don't (actually, can't) move between threads. Vibe.d uses 
regular D fibers, so it's true there as well.

The main reason why it's not currently possible is data being 
thread-local by default. If fibers could move, a fiber accessing a 
thread-local data would continue accessing the same data at the same 
address but it would be different data on that thread.

This huge thread has interesting discussions on not moving fibers 
between threads:

   http://forum.dlang.org/post/mf3hk7$1ucr$1@digitalmars.com

Ali



More information about the Digitalmars-d-learn mailing list