Re: how to stop a variable from being optimized out

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 12:50:53 +, Rory wrote: > On Tuesday, 24 February 2015 at 06:48:26 UTC, ketmar wrote: >> but why do you need this? just use `atomicLoad` to get shared variable >> value, it will do the right caching. > > Nice! Thanks. Tested atomicLoad and it is slightly faster for my non

Re: how to stop a variable from being optimized out

2015-02-24 Thread Rory via Digitalmars-d-learn
On Tuesday, 24 February 2015 at 06:48:26 UTC, ketmar wrote: but why do you need this? just use `atomicLoad` to get shared variable value, it will do the right caching. Nice! Thanks. Tested atomicLoad and it is slightly faster for my non blocking queue.

Re: how to stop a variable from being optimized out

2015-02-23 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 06:29:33 +, Rory wrote: > Is there a way I can stop "current" from being optimized out without > using "volatile"? but why do you need this? just use `atomicLoad` to get shared variable value, it will do the right caching. signature.asc Description: PGP signature

how to stop a variable from being optimized out

2015-02-23 Thread Rory via Digitalmars-d-learn
Hi, Is there a way I can stop "current" from being optimized out without using "volatile"? The compiler is suggesting I replace "volatile" with "synchronized" but I don't want it synchronized? Would a memory barrier work? shared n = new int(value); for (;;) { volatile auto current = payloa