cas

Stores 'writeThis' to the memory referenced by 'here' if the value referenced by 'here' is equal to 'ifThis'. This operation is both lock-free and atomic.

  1. bool cas(T* here, V1 ifThis, V2 writeThis)
  2. bool cas(shared(T)* here, V1 ifThis, V2 writeThis)
    pure nothrow @nogc @trusted
    bool
    cas
    (
    shared(T)* here
    ,,)
    if (
    !is(T == class) &&
    (
    is(T : V1) ||
    is(shared T : V1)
    )
    )
    in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
  3. bool cas(shared(T)* here, shared(V1) ifThis, shared(V2) writeThis)
  4. bool cas(T* here, T* ifThis, V writeThis)
  5. bool cas(shared(T)* here, V1* ifThis, V2 writeThis)
  6. bool cas(shared(T)* here, shared(T)* ifThis, shared(V) writeThis)
  7. T arg2;

Parameters

here
Type: shared(T)*

The address of the destination variable.

writeThis
Type: V2

The value to store.

ifThis
Type: V1

The comparison value.

Return Value

Type: bool

true if the store occurred, false if not.

Suggestion Box / Bug Report