Very limited shared promotion

Manu turkeyman at gmail.com
Sat Jun 22 00:33:41 UTC 2019


On Sat., 22 Jun. 2019, 9:40 am Walter Bright via Digitalmars-d, <
digitalmars-d at puremagic.com> wrote:

> On 6/21/2019 5:07 AM, Manu wrote:
> > There is no "between threads" unless you have already entered @trusted
> land.
> > The reason for my proposal in the OP is precisely to prevent passing
> > data to other threads, that's the key that makes this promotion safe.
>
> Scope doesn't do that. I keep saying this. But the premise is strange,
> anyway,
> as why would you want to convert a reference to shared if not to bass it
> to
> another thread?
>

Because it's safe to do from the calling scope's perspective, and that's
the needed entry vector into a @trusted solution.

It is also useful too in some cases to reduce needlessly overloading
methods which have a threadsafe implementation.

> Can you show how you managed to get a ref to another thread without
> > entering @trusted?
> There's no such thing as a ref to another thread. You can pass a ref to
> another
> thread in a scope function, as long as the ref doesn't survive the scope
> of foo().
>
> The compiler cannot check that, though, and so cannot bless the implicit
> conversion to shared. I've said this 4 or 5 times now.
>

Compiler is not required to check the users work in @trusted code. It
assumes the user conformed with language requirements.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20190622/82d3d950/attachment.html>


More information about the Digitalmars-d mailing list