Opportunities for D

Sean Kelly via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 10 08:18:25 PDT 2014


On Thursday, 10 July 2014 at 11:03:20 UTC, logicchains wrote:
>
> Reading the code in the pull request [1], for instance, makes 
> me wonder how to tell if `spawn()` is spawning a thread or a 
> fibre. Can a tid refer to a fibre? If so, why's it called a 
> thread ID, and how do I tell if a particular tid refers to a 
> thread or fibre? It would be great to have these kinds of 
> questions answered in an easily available reference (for 
> instance, the documentation for std.concurrency, which 
> currently doesn't even mention fibres or vibe.d).

That was a deliberate design decision--you're not supposed to 
know, or care, what it's spawning.  This also allows up to change 
the scheduling algorithm without affecting user code.  That said, 
because statics are thread-local by default, and because 
implementing fiber-local storage in a C-compatible language would 
be difficult, the scheduler is user-configurable.  So there is 
some visibility into this, just not as a part of the normal 
spawn/send/receive flow.


More information about the Digitalmars-d mailing list