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)
  3. bool cas(shared(T)* here, shared(V1) ifThis, shared(V2) writeThis)
    pure nothrow @nogc @trusted
    bool
    cas
    (
    shared(T)* here
    ,
    shared(V1) ifThis
    ,
    shared(V2) writeThis
    )
    if (
    is(T == class)
    )
    in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
  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. alias Thunk2 = V2

Parameters

here
Type: shared(T)*

The address of the destination variable.

writeThis
Type: shared(V2)

The value to store.

ifThis
Type: shared(V1)

The comparison value.

Return Value

Type: bool

true if the store occurred, false if not.

Suggestion Box / Bug Report