Thread overview
[Issue 6587] New: std.parallelism
Sep 01, 2011
Andrew Wiley
[Issue 6587] std.parallelism's Task cannot handle immutable values
Sep 01, 2011
Andrew Wiley
Sep 01, 2011
David Simcha
Sep 03, 2011
David Simcha
Jan 13, 2012
David Simcha
September 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6587

           Summary: std.parallelism
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: debio264@gmail.com


--- Comment #0 from Andrew Wiley <debio264@gmail.com> 2011-08-31 22:34:42 PDT ---


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6587


Andrew Wiley <debio264@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|Other                       |All
            Summary|std.parallelism             |std.parallelism's Task
                   |                            |cannot handle immutable
                   |                            |values
         OS/Version|Windows                     |All


--- Comment #1 from Andrew Wiley <debio264@gmail.com> 2011-08-31 22:39:40 PDT ---
When creating Tasks to run on a TaskPool using std.parallelism, it looks like I can't call functions that have immutable objects:

code:
import std.parallelism;

class Test {
}

void doSomething(immutable(Test) test) {
}

void main() {
        immutable(Test) test = new immutable(Test)();
        taskPool().put(task!(doSomething)(test));
}


compiler output:
Error: can only initialize const member __args_field_0 inside constructor
Error: this is not mutable
/usr/include/d2/4.6.0/std/parallelism.d:734: Error: template instance
std.parallelism.Task!(doSomething,immutable(Test)) error instantiating
tasktest.d:11:        instantiated from here:
task!(doSomething,immutable(Test))


Is this something that can be fixed, or does this depend on having tail const support (which would hopefully work for immutable as well)? This use case seems particularly important as immutability is the simplest way to ensure safe multithreading.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6587


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha@yahoo.com


--- Comment #2 from David Simcha <dsimcha@yahoo.com> 2011-09-01 06:38:52 PDT ---
This should work, but I had neglected to put a test in for it.  Anyhow, the underlying reason it doesn't work is Bug 6588.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 03, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6587



--- Comment #3 from David Simcha <dsimcha@yahoo.com> 2011-09-03 08:24:38 PDT ---
I found a workaround for 6588 and put it into a larger pull request with various improvements to std.parallelism:

https://github.com/D-Programming-Language/phobos/pull/217

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 13, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6587


David Simcha <dsimcha@yahoo.com> changed:

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


--- Comment #4 from David Simcha <dsimcha@yahoo.com> 2012-01-12 20:32:11 PST ---
This has been fixed for a few releases.  Closing.

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