View source code
Display the source code in core/atomic.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Template core.atomic.cas

Performs either compare-and-set or compare-and-swap (or exchange).

template cas(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder.seq) ;

There are two categories of overloads in this template: The first category does a simple compare-and-set. The comparison value (ifThis) is treated as an rvalue.

The second category does a compare-and-swap (a.k.a. compare-and-exchange), and expects ifThis to be a pointer type, where the previous value of here will be written.

This operation is both lock-free and atomic.

Contained Functions

NameDescription
cas Compare-and-set for non-shared values
cas Compare-and-set for shared value type
cas Compare-and-set for shared reference type (class)
cas Compare-and-exchange for non-shared types
cas Compare and exchange for mixed-sharedness types
cas Compare-and-exchange for class

Parameters

NameDescription
here The address of the destination variable.
writeThis The value to store.
ifThis The comparison value.

Returns

true if the store occurred, false if not.

Authors

Sean Kelly, Alex Rønne Petersen, Manu Evans

License

Boost License 1.0