just::thread Support Forum
General Category => General Discussion about just::thread => Topic started by: TA on February 17, 2011, 03:22:57 PM
-
Anthony,
Could you please explain what ATOMIC_VAR_INIT is used for? I couldn't find any useful information on that (or maybe I just coulnd't get it). As far as I understood it is used to initialize atomic variables in some special way, but what kind of initialization is done? When it might be useful? All the examples I could find was
atomic<int> t = ATOMIC_VAR_INIT(2);
why not just
atomic<int> t = 2;
what's the difference?
-
Could you please explain what ATOMIC_VAR_INIT is used for? I couldn't find any useful information on that (or maybe I just coulnd't get it). As far as I understood it is used to initialize atomic variables in some special way, but what kind of initialization is done? When it might be useful? All the examples I could find was
atomic<int> t = ATOMIC_VAR_INIT(2);
why not just
atomic<int> t = 2;
what's the difference?
ATOMIC_VAR_INIT is there for C compatibility, since you can't write
atomic_int i(3);
in C, but you can write
atomic_int i=ATOMIC_VAR_INIT(3);
in both C and C++.
-
Got it. Thanks.