Fibers

Sean Kelly sean at invisibleduck.org
Tue Oct 21 22:06:07 PDT 2008


Bill Baxter wrote:
> On Wed, Oct 22, 2008 at 11:51 AM, dsimcha <dsimcha at yahoo.com> wrote:
>> I noticed that, in D 2.20, we now have an implementation of fibers for D2.  I
>> understand the basic differences between a fiber and a thread (preemptive vs.
>> cooperative multitasking, threads can take advantage of multicore, fibers
>> can't).  However, from a more practical point of view, I've become curious,
>> what are fibers actually good for?  What can be done with fibers that either
>> can't be done at all or can't be done as efficiently/elegantly/safely with
>> threads?
> 
> Oh, they're in core.thread!  Huh.  Very interesting.

Yup.  Fibers are a part of the runtime because their memory must be 
exposed to the GC collection mechanism.

> These are stack threads right?

Yeah.  I chose 'fiber' because it fits with the 'thread' terminology, 
but the implementation is based on Mik's StackThreads.  At the moment, 
there are some issues with fibers using GDC, but hopefully they'll be 
sorted out by the time druntime supports GDC :-)


Sean



More information about the Digitalmars-d mailing list