[phobos] Parallelism in Phobos

Andrei Alexandrescu andrei at erdani.com
Fri Sep 10 11:20:46 PDT 2010


The latter. Anyway, my vetoing abilities are largely overrated.

Andrei

On 9/10/10 13:16 CDT, David Simcha wrote:
> Andrei,
>
> Does my decision that std.parallelism should be a "here be dragons"
> module and there's no reasonably way to make it safe make it a
> non-starter for you, or have you just not gotten around to reviewing it?
>
> --Dave
>
> On Sun, Sep 5, 2010 at 11:05 AM, David Simcha <dsimcha at gmail.com
> <mailto:dsimcha at gmail.com>> wrote:
>
>     It doesn't use std.concurrency.  It just uses core.thread.  For now,
>     core.thread doesn't take a shared delegate, meaning it bypasses the
>     entire shared system.  Sean said a while back that eventually it
>     would start taking a shared delegate.  When it does, I'll simply
>     cast the workLoop delegate to shared, thus bypassing the entire
>     shared system again.  As the warning at the top of the module
>     states, it does subvert the type system to achieve completely
>     unchecked sharing, though this doesn't require relying on
>     implementation bugs, just unsafe casts.
>
>     I've thought about this enough that I think trying to improve the
>     type system to make this lib use something other than completely
>     unchecked sharing, while still being useful for pedal-to-metal
>     parallelism, is a lost cause at least for D2. *Maybe* it's do-able
>     in D3.  Even if it's technically do-able, I think it would make the
>     library so inefficient and/or the API so obtuse that for something
>     like this I feel strongly that unsafe "here be dragons" + @system is
>     the right answer.  Those that want a safe multithreading model can
>     simply not use this module.
>
>     I am completely in favor of std.parallelism coming w/ a huge warning
>     on it, being @system as opposed to @trusted, and not being
>     considered the "flagship" multhreading model.  However, even TDPL
>     mentions the possibility of using casts to achieve unchecked
>     sharing, which is exactly what this module will do when core.thread
>     starts taking shared delegates.  If D is still supposed to be a
>     systems language, I think dangerous, pedal-to-metal libraries like
>     this have their place in Phobos, as long as it's clear that that's
>     what they are.
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list