[phobos] Parallelism in Phobos

David Simcha dsimcha at gmail.com
Fri Sep 10 11:16:43 PDT 2010


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> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100910/3a305602/attachment.html>


More information about the phobos mailing list