AtomicReadModifyWriteOperation

public enum AtomicReadModifyWriteOperation

AtomicReadModifyWriteOperation enumerates the kinds of supported atomic read-write-modify operations.

  • Set the new value and return the one old

    *ptr = val
    

    Declaration

    Swift

    case xchg
  • add

    Add a value and return the old one

    *ptr = *ptr + val
    

    Declaration

    Swift

    case add
  • sub

    Subtract a value and return the old one

    *ptr = *ptr - val
    

    Declaration

    Swift

    case sub
  • and

    And a value and return the old one

    *ptr = *ptr & val
    

    Declaration

    Swift

    case and
  • Not-And a value and return the old one

    *ptr = ~(*ptr & val)
    

    Declaration

    Swift

    case nand
  • or

    OR a value and return the old one

    *ptr = *ptr | val
    

    Declaration

    Swift

    case or
  • xor

    Xor a value and return the old one

    *ptr = *ptr ^ val
    

    Declaration

    Swift

    case xor
  • max

    Sets the value if it’s greater than the original using a signed comparison and return the old one.

    // Using a signed comparison
    *ptr = *ptr > val ? *ptr : val
    

    Declaration

    Swift

    case max
  • min

    Sets the value if it’s Smaller than the original using a signed comparison and return the old one.

    // Using a signed comparison
    *ptr = *ptr < val ? *ptr : val
    

    Declaration

    Swift

    case min
  • Sets the value if it’s greater than the original using an unsigned comparison and return the old one.

    // Using an unsigned comparison
    *ptr = *ptr > val ? *ptr : val
    

    Declaration

    Swift

    case umax
  • Sets the value if it’s greater than the original using an unsigned comparison and return the old one.

    // Using an unsigned comparison
    *ptr = *ptr < val ? *ptr : val
    

    Declaration

    Swift

    case umin