Unsigned int API:

Module shared_atomic.atomic_uint on Linux and macOS

class shared_atomic.atomic_uint.atomic_uint

int provide atomic operations, the unsigned int takes 8 bytes

:attributes

value: read/write value of the integer

constructor of atomic_uint

Parameters
  • value – read/write value of the integer

  • mode – ‘s’ or ‘singleprocessing’ for single process, ‘m’ or ‘multiprocessing’ for multiprocessing

  • windows_unix_compatibility – dummy parameter on unix platform, used on windows platform to indicate whether the source code should be compatible with unix platform

get()

get the contents of atomic_uint atomically.

Returns

the int value

set()

set the contents of atomic_uint atomically.

Parameters

value – the integer value to set from

Returns

None

uint_add_and_fetch()

increment and fetch atomically

Parameters

n – data to add

Returns

sum of the 2 values

uint_and_and_fetch()

bitwise AND and fetch the result atomically

Parameters

n – data to AND

Returns

the result value

uint_compare_and_set()

Compare and set atomically. This compares the contents of self with the contents of e. If equal, the operation is a read-modify-write operation that writes n into self. If they are not equal, the operation is a read and the current contents of self are written into e.

Parameters
  • e – atomic_uint object

  • n – the integer value to set from

Returns

if self is equal to e return True, else return False

uint_compare_and_set_value()

Compare and set atomically. This compares the contents of self with the contents of n. If equal, the operation is a read-modify-write operation that writes e into self. If they are not equal, no operation will be taken.

Parameters
  • e – The exchange value

  • n – The value to compare to

Returns

initial value

uint_fetch_and_add()

fetch and increment atomically

Parameters

n – data to add

Returns

original value

uint_fetch_and_and()

fetch then bitwise AND atomically

Parameters

n – data to AND

Returns

original value

uint_fetch_and_nand()

fetch then bitwise NAND atomically

Parameters

n – data to NAND

Returns

original value

uint_fetch_and_or()

fetch then bitwise OR atomically

Parameters

n – data to OR

Returns

original value

uint_fetch_and_sub()

fetch and subtract atomically

Parameters

n – data to subtract

Returns

original value

uint_fetch_and_xor()

fetch then bitwise XOR atomically

Parameters

n – data to XOR

Returns

original value

uint_get_and_set()

get and set contents of atomic_uint atomically.

Parameters

n – the integer value to set from

Returns

the original int value

uint_nand_and_fetch()

bitwise NAND and fetch the result atomically

Parameters

n – data to NAND

Returns

the result value

uint_or_and_fetch()

bitwise XOR and fetch the result atomically

Parameters

n – data to OR

Returns

the result value

uint_shift()

value exchange between 3 atomic_uints in 2 groups atomically, store n in self after store self in r.

Parameters
  • n – the atomic_uint n

  • r – the atomic_uint r

Returns

None

uint_store()

Store value atomically.

Parameters

n – the atomic_uint to set from

Returns

None

uint_sub_and_fetch()

sub and fetch atomically

Parameters

n – data to subtract

Returns

difference of the 2 values

uint_xor_and_fetch()

bitwise XOR and fetch the result atomically

Parameters

n – data to XOR

Returns

the result value

shared_atomic.atomic_uint.uint_add_and_fetch()

increment and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_uint.uint_and_and_fetch()

Bitwise AND and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to AND

Returns

the result value

shared_atomic.atomic_uint.uint_compare_and_set()

Compare and set atomically. This compares the contents of integer with the contents of e. If equal, the operation is a read-modify-write operation that writes n into integer. If they are not equal, the operation is a read and the current contents of integer are written into e.

Parameters
  • integer – atomic_uint object

  • e – atomic_uint object

  • n – the integer value to set from

Returns

if integer is equal to e return True, else return False

shared_atomic.atomic_uint.uint_compare_and_set_value()

Compare and swap atomically, This compares the contents of atomic_uint integer with the contents of n. If equal, the operation is a read-modify-write operation that writes e into integer. If they are not equal, No operation is performed.

Parameters
  • integer – the atomic_uint

  • e – the integer value

  • n – the integer value

Returns

the initial value

shared_atomic.atomic_uint.uint_fetch_and_add()

increment and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to add

Returns

the initial value

shared_atomic.atomic_uint.uint_fetch_and_and()

fetch then bitwise AND atomically

Parameters
  • integer – the atomic_uint

  • n – data to AND

Returns

the initial value

shared_atomic.atomic_uint.uint_fetch_and_nand()

fetch then bitwise NAND atomically

Parameters
  • integer – the atomic_uint

  • n – data to NAND

Returns

the initial value

shared_atomic.atomic_uint.uint_fetch_and_or()

fetch then bitwise OR atomically

Parameters
  • integer – the atomic_uint

  • n – data to OR

Returns

the initial value

shared_atomic.atomic_uint.uint_fetch_and_sub()

subtract and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to subtract

Returns

the initial value

shared_atomic.atomic_uint.uint_fetch_and_xor()

fetch then bitwise XOR atomically

Parameters
  • integer – the atomic_uint

  • n – data to XOR

Returns

the initial value

shared_atomic.atomic_uint.uint_get()

get the contents of atomic_uint atomically.

Parameters

integer – the atomic_uint to get

Returns

the int value

shared_atomic.atomic_uint.uint_get_and_set()

get and set contents of atomic_uint atomically.

Parameters
  • integer – the atomic_uint

  • n – the integer value to set from

Returns

the original int value

shared_atomic.atomic_uint.uint_nand_and_fetch()

Bitwise NAND and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to NAND

Returns

the result value

shared_atomic.atomic_uint.uint_or_and_fetch()

Bitwise OR and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to OR

Returns

the result value

shared_atomic.atomic_uint.uint_set()

set the contents of atomic_uint atomically.

Parameters
  • integer – the atomic_uint to set

  • n – the integer value to set from

Returns

None

shared_atomic.atomic_uint.uint_shift()

value exchange between 3 atomic_uint in 2 groups atomically, store n in integer after store integer in r.

Parameters
  • integer – the atomic_uint integer

  • n – the atomic_uint n

  • r – the atomic_uint r

Returns

None

shared_atomic.atomic_uint.uint_store()

Store value atomically.

Parameters
  • integer – the atomic_uint to set

  • n – the atomic_uint to set from

Returns

None

shared_atomic.atomic_uint.uint_sub_and_fetch()

sub and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_uint.uint_xor_and_fetch()

Bitwise XOR and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to XOR

Returns

the result value