January 25, 2014
Am Sat, 25 Jan 2014 21:41:20 +0000
schrieb "Kagamin" <spam@here.lot>:

> On Saturday, 25 January 2014 at 10:00:58 UTC, Johannes Pfau wrote:
> > (For example it isn't valid in D to access a shared variable
> > with
> > normal operations anyway, AFAIK. You need to use the atomicOp
> > things
> > and these will the worry about the hardware part, using the
> > correct
> > instructions and so on)
> 
> Is it invalid to access shared data on stack too? How about closures?
> 

I'm not sure about the details - shared hasn't been completely implemented or even specified yet. AFAIK the most recent idea was that shared does basically nothing but prevents direct access to variables. Synchronized statements then remove the shared qualifier and you can access the variables as usual. Atomic OPs also work with shared variables. Using locks manually then probably requires casting away shared.

However, this part of the language is really unfinished. I hoped we could at least use shared as a replacement for volatile, but as you said in your other reply we probably can't.

January 25, 2014
Am Sat, 25 Jan 2014 21:48:39 +0000
schrieb "Kagamin" <spam@here.lot>:

> Also if you read a shared value with atomicLoad every time, this disallows caching in registers or on stack, which is also performance hit. The shared value should be read once and cached if possible.

Yes, I came to the same conclusion. If we combine volatile
and shared into one qualifier we'll always have a certain performance
hit.

Great, now we have to convince Walter that we have to undeprecate volatile for embedded programming...
January 26, 2014
On Saturday, 25 January 2014 at 23:20:47 UTC, Johannes Pfau wrote:
> Yes, I came to the same conclusion. If we combine volatile
> and shared into one qualifier we'll always have a certain performance
> hit.

This is what GDC does now.
1 2
Next ›   Last »