casWeak

Stores 'writeThis' to the memory referenced by 'here' if the value referenced by 'here' is equal to 'ifThis'. The 'weak' version of cas may spuriously fail. It is recommended to use casWeak only when cas would be used in a loop. This operation is both lock-free and atomic. *

  1. bool casWeak(T* here, V1 ifThis, V2 writeThis)
  2. bool casWeak(shared(T)* here, V1 ifThis, V2 writeThis)
  3. bool casWeak(shared(T)* here, shared(V1) ifThis, shared(V2) writeThis)
    pure nothrow @nogc @trusted
    bool
    casWeak
    (
    shared(T)* here
    ,
    shared(V1) ifThis
    ,
    shared(V2) writeThis
    )
    if (
    is(T == class)
    )
    in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned")
  4. bool casWeak(T* here, T* ifThis, V writeThis)
  5. bool casWeak(shared(T)* here, V1* ifThis, V2 writeThis)
  6. bool casWeak(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