
21 Sep
2008
21 Sep
'08
2 p.m.
cg wrote:
Janek Kozicki wrote:
Hi,
I looked through Boost.Threads and Boost.Interprocess libraries, but (as far as I can tell) none of them offers me simple:
class Foo { boost::atomic<int> bar; }
which would mean that *ALL* attempts to access bar would be atomic, eg. bar=10;
If all you're wanting is atomic operators, ACE's (http://www.cs.wustl.edu/~schmidt/ACE.html) ACE_Atomic_Op template (http://www.dre.vanderbilt.edu/Doxygen/5.6.6/html/ace/a00029.html) provides that. It synchronizes all arithmetic, assignment, and comparison operators. I've used it before to do intrusive reference counting on shared closures. A utility class that just synchronizes operations shouldn't be too hard to write "boost" way. --Kris