Very limited shared promotion

Manu turkeyman at gmail.com
Sat Jun 22 00:26:34 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?
>
>
> > 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.
>
>
> > There's no possibility of the synchronisation
> > issue arising unless there's some way to escape a scope ref to another
> > thread, which scope prevents.
>
> You're inventing semantics for scope that I've repeatedly told you are not
> there.


I've asked you 5 or 6 times to show how to pass a pointer to another thread
without violating scope.
Can you show it? You keep saying you can.


> We're not talking about atomic reads here, we're talking about memory
> barriers.
>
> I recommend watching:
>
> https://www.youtube.com/watch?v=A8eCGOqgvH4
> https://www.youtube.com/watch?v=KeLBd2EJLOU
>
> as you and I are not speaking the same language. In particular the
> sections on
> how atomics create sequentially consistent data-race-free reads and writes
> of
> variables. Not needing to read x atomically after foo() ends is just plain
> wrong.


You need an acquire fence before the function returns, it's trivial.
In many cases though you don't need one, because you may have already
required one to determine that the workload is complete in the first place.
Don't attempt this in the @system language. Just let it be, we know what
we're doing.

If you want @safe expansion, that's future work, and I personally couldn't
care less about that work. I can create safe libraries with @trusted
functions, and I could do it _right now_.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20190622/18ea42f9/attachment.html>


More information about the Digitalmars-d mailing list