Bug 8418 – core.thread.Fiber is a Coroutine or Semi-Coroutine?

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-22T18:28:52Z
Last change time
2024-12-07T13:32:04Z
Assigned to
No Owner
Creator
Masahiro Nakagawa
Moved to GitHub: dmd#17244 →

Comments

Comment #0 by repeatedly — 2012-07-22T18:28:52Z
First, I tried following Coroutine code with Fiber, but caused segmentation fault. ----- Fiber child, parent; child = new Fiber(delegate() { writeln("before call parent"); parent.call(); // invoke parent fiber writeln("after call parent"); }); parent = new Fiber({ writeln("before call child"); child.call(); writeln("after call child"); }); parent.call(); % dmd -run co.d before call child before call parent after call child --- killed by signal 11 ----- Second, I tried Semi-Coroutine code. It works fine. ----- Fiber child, parent; child = new Fiber(delegate() { writeln("before call parent"); Fiber.yield(); // return to parent. writeln("after call parent"); }); parent = new Fiber({ writeln("before call child"); child.call(); writeln("after call child"); }); parent.call(); % dmd -run co.d before call child before call parent after call child ----- core.thread.Fiber now provides Semi-Coroutine APIs(call and yield), so I guess former code is invalid. If so, Fiber's document should describe such limitation.
Comment #1 by alex — 2012-10-09T18:34:06Z
Can you please send a pull request with a doc fix? You probably know the API better than I do.
Comment #2 by robert.schadek — 2024-12-07T13:32:04Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17244 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB