AtomicInt allows non-blocking synchronization of multithreaded code with respect to reference counting and other critical operations in parallel algorithm implementations. This class is used extensively by PCL code to implement copy-on-write shared containers and container operations in a thread-safe way. An example is the ReferenceCounter class, which is at the hearth of most PCL container and image classes.
AtomicInt implements the following synchronization primitives on integers:
reference
dereference
test-and-set
fetch-and-store
fetch-and-add
- See also
- ReferenceCounter
Definition at line 94 of file Atomic.h.
bool pcl::AtomicInt::TestAndSet |
( |
int |
expectedValue, |
|
|
int |
newValue |
|
) |
| |
|
inline |
Atomic test-and-set operation.
If the current value of this object is equal to expectedValue, this function assigns newValue to this object and returns true. If the current value is not equal to expectedValue, this function performs no operation and returns false.
- Note
- This operation is guaranteed to be atomic on all supported platforms and architectures.
Definition at line 302 of file Atomic.h.
Referenced by pcl::AutoReentrancyGuard::AutoReentrancyGuard().