On Saturday, December 03, 2011 18:32:15 Andrej Mitrovic wrote: > I thought this wasn't allowed: > > shared uint threadsCount; > > void bumpThreadsCount() > { > ++threadsCount; > } > > void main() > { > } > > According to TDPL it should error and we should use atomicOp from > std.concurrency instead. atomicOp is what I've used so far if I had to > use shared variables. Has ++ suddenly become atomic automatically or > is this a bug?
Where in TDPL does it say this? Requiring that all operations on a shared object be atomic would be highly restrictive. Sure, if you use anything other than an atomic operation on a shared object and don't use a synchronized block or a mutex or the like, you risk race conditions, but if every operation on a shared object had to actually be atomic, you couldn't do much of anything to them. - Jonathan M Davis