Re: shared methods

2014-01-26 Thread Kagamin
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.

Re: shared methods

2014-01-25 Thread Johannes Pfau
Am Fri, 24 Jan 2014 22:30:13 + schrieb Kagamin s...@here.lot: http://igoro.com/archive/volatile-keyword-in-c-memory-model-explained/ As I understand, because Itanium doesn't have cache coherency, a memory fence is needed to implement volatile load and store. On x86 load and store are

Re: shared methods

2014-01-25 Thread Kagamin
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)

Re: shared methods

2014-01-25 Thread Kagamin
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.

Re: shared methods

2014-01-25 Thread Johannes Pfau
Am Sat, 25 Jan 2014 21:41:20 + schrieb Kagamin s...@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

Re: shared methods

2014-01-25 Thread Johannes Pfau
Am Sat, 25 Jan 2014 21:48:39 + schrieb Kagamin s...@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

Re: shared methods

2014-01-24 Thread Kagamin
for example http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming

Re: shared methods

2014-01-24 Thread Kagamin
http://igoro.com/archive/volatile-keyword-in-c-memory-model-explained/ As I understand, because Itanium doesn't have cache coherency, a memory fence is needed to implement volatile load and store. On x86 load and store are already volatile because of cache coherency, so fences are not needed.

Re: shared methods

2014-01-22 Thread Benjamin Thaut
Am 22.01.2014 06:16, schrieb unknown soldier: I'm confused by shared and how to use it. import std.stdio; class Foo { File logFile; void log(in string line) shared { synchronized(this){ logFile.writeln(line); } } } This (or the equivalent code in my full

Re: shared methods

2014-01-22 Thread unknown soldier
The compiler does not do this for you, because it can not know if accessing any member is truly thread-safe. You might share the logFile with other instances of Foo. This would be a case where the compiler would wrongly remove the shared from this, if it would do so automatically inside

shared methods

2014-01-21 Thread unknown soldier
I'm confused by shared and how to use it. import std.stdio; class Foo { File logFile; void log(in string line) shared { synchronized(this){ logFile.writeln(line); } } } This (or the equivalent code in my full size program) won't compile: source/log.d(256):