www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Fibers under the hood

reply Jonathan Marler <johnnymarler gmail.com> writes:
I've googled and searched through the forums but haven't found 
too much on how fibers are implemented.  How does yield return 
execution to the caller but then resume execution in the same 
place on the next call?  Also some information on how the fiber 
call stack works would be nice.  I'm assuming it allocates the 
stack on the GC heap.  If so, what is the default size and is 
that configurable?  Any information or pointers to resources that 
provide this information would be helpful.  Thanks.
Jun 08 2016
parent reply Nikolay <sibnick gmail.com> writes:
On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote:
 I've googled and searched through the forums but haven't found 
 too much on how fibers are implemented.  How does yield return 
 execution to the caller but then resume execution in the same 
 place on the next call?  Also some information on how the fiber 
 call stack works would be nice.  I'm assuming it allocates the 
 stack on the GC heap.  If so, what is the default size and is 
 that configurable?  Any information or pointers to resources 
 that provide this information would be helpful.  Thanks.
See "Documentation of Fiber internals" inside https://github.com/dlang/druntime/blob/master/src/core/thread.d
Jun 08 2016
parent reply Jonathan Marler <johnnymarler gmail.com> writes:
On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote:
 On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote:
 I've googled and searched through the forums but haven't found 
 too much on how fibers are implemented.  How does yield return 
 execution to the caller but then resume execution in the same 
 place on the next call?  Also some information on how the 
 fiber call stack works would be nice.  I'm assuming it 
 allocates the stack on the GC heap.  If so, what is the 
 default size and is that configurable?  Any information or 
 pointers to resources that provide this information would be 
 helpful.  Thanks.
See "Documentation of Fiber internals" inside https://github.com/dlang/druntime/blob/master/src/core/thread.d
Exactly what I was looking for, thanks. Would be nice if this documentation was published on the website somewhere (probably in the Fiber library documentation).
Jun 08 2016
parent reply Andrew Edwards <edwards.ac gmail.com> writes:
On 6/9/16 2:15 PM, Jonathan Marler wrote:
 On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote:
 On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote:
 I've googled and searched through the forums but haven't found too
 much on how fibers are implemented.  How does yield return execution
 to the caller but then resume execution in the same place on the next
 call?  Also some information on how the fiber call stack works would
 be nice.  I'm assuming it allocates the stack on the GC heap.  If so,
 what is the default size and is that configurable?  Any information
 or pointers to resources that provide this information would be
 helpful.  Thanks.
See "Documentation of Fiber internals" inside https://github.com/dlang/druntime/blob/master/src/core/thread.d
Exactly what I was looking for, thanks. Would be nice if this documentation was published on the website somewhere (probably in the Fiber library documentation).
Might be wrong but did you mean this? https://dlang.org/phobos/core_thread.html#.Fiber
Jun 09 2016
parent reply Jonathan Marler <johnnymarler gmail.com> writes:
On Thursday, 9 June 2016 at 11:45:01 UTC, Andrew Edwards wrote:
 On 6/9/16 2:15 PM, Jonathan Marler wrote:
 On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote:
 On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler 
 wrote:
 I've googled and searched through the forums but haven't 
 found too
 much on how fibers are implemented.  How does yield return 
 execution
 to the caller but then resume execution in the same place on 
 the next
 call?  Also some information on how the fiber call stack 
 works would
 be nice.  I'm assuming it allocates the stack on the GC 
 heap.  If so,
 what is the default size and is that configurable?  Any 
 information
 or pointers to resources that provide this information would 
 be
 helpful.  Thanks.
See "Documentation of Fiber internals" inside https://github.com/dlang/druntime/blob/master/src/core/thread.d
Exactly what I was looking for, thanks. Would be nice if this documentation was published on the website somewhere (probably in the Fiber library documentation).
Might be wrong but did you mean this? https://dlang.org/phobos/core_thread.html#.Fiber
I don't see that documentation anywhere on that page. That's where I looked first actually. It may or may not make sense to include that doc in the api documentation, but I think it would definitely make sense to include it on it's own page that talks about how fibers are implemented. This information is more about learning about fibers as opposed to how to use them (which is all that most people want to know).
Jun 09 2016
parent Jack Stouffer <jack jackstouffer.com> writes:
On Thursday, 9 June 2016 at 16:13:21 UTC, Jonathan Marler wrote:
 I don't see that documentation anywhere on that page.
https://issues.dlang.org/show_bug.cgi?id=16148
Jun 09 2016