Subject: Re: [boost] [atomic] Availability detection
From: Helge Bahmann (hcb_at_[hidden])
Date: 2010-01-31 06:32:33
Am Sunday 31 January 2010 10:07:02 schrieb Andrey Semashev:
> Will there be a way to detect if specific operations over a specific
> type are available atomically on the current platform?
All operations on all types will always be atomic. The implementation
transparently falls back to using locking internally if there is no way to
guarantee atomicity otherwise.
What you could want to detect is lock-freedom, and this is defined per type:
either all operations on a type are lock-free, or none is. Currently the only
way is querying the "is_lock_free" property at run-time, but there should
probably be macros for querying at compile-time.
> That is, if I
> know that atomic operations are emulated with locks, I want to fall back
> to another branch of my code with explicit locks, rather than the
> emulated atomics.
Yes, this would be rather useful. Currently I know of one corner case
(uint64_t on x86_32) where this distinction would actually have to be made at