[Issue 6126] std.parallelism does not re-throw exception

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 8 19:35:16 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6126


David Simcha <dsimcha at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #1 from David Simcha <dsimcha at yahoo.com> 2011-06-08 19:30:43 PDT ---
Exceptions thrown from within tasks are re-thrown when you call done(),
workForce(), yieldForce(), or spinForce() on the Task object.  You created an
anonymous task and never called any of these functions.  The following slightly
modified code does re-throw the exception.

import std.exception;
import std.parallelism;

void foo(int task)
{
    enforce(task != 4);
}

void main()
{
    int[] tasks = [1, 2, 3];
    auto t = task!foo(4);
    taskPool.put(t);
    foreach (task; taskPool.parallel(tasks))
    {
        foo(task);
    }

    t.yieldForce();
}

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


More information about the Digitalmars-d-bugs mailing list