www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8418] New: core.thread.Fiber is a Coroutine or Semi-Coroutine?

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8418

           Summary: core.thread.Fiber is a Coroutine or Semi-Coroutine?
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: repeatedly gmail.com



18:28:52 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 22 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8418


Alex Rønne Petersen <alex lycus.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alex lycus.org



CEST ---
Can you please send a pull request with a doc fix? You probably know the API
better than I do.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 09 2012