Unsigned int API:

Module shared_atomic

class shared_atomic.atomic_uint. atomic_uint ( value : size_t , mode : unicode = 'singleprocessing' , windows_unix_compatibility : bool = False )

Unsigned int provide atomic operations, the unsigned int takes 8 bytes, no such class on windows x64, windows_unix_compatibility is useless :attributes

reference: readonly pointer to the integer value: read/write value of the integer mode: readonly ‘s’ for single process, ‘m’ for multiprocessing, on windows platform, only singleprocessing is supported windows_unix_compatibility: readonly whether the source code should be compatible with windows x64

uint_add_and_fetch ( n : size_t ) size_t

increment and fetch atomically

Parameters
  • v – pointer of value to add to and get

  • n – data to add

Returns

sum of the 2 values

uint_and_and_fetch ( n : size_t ) size_t

bitwise AND and fetch the result atomically

Parameters
  • v – pointer of value to AND to

  • n – data to AND

Returns

resulted value

uint_compare_and_set ( e : self_atomic_uint , n : size_t ) bool

Compare and set atomically. This compares the contents of v 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 v are written into e. :param v: pointer of v :param e: pointer of e :param n: value to be set :return: whether the contents of v and contents of e is the same

uint_compare_and_set_value ( e : size_t , n : size_t ) size_t

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

param v

A pointer to the destination value

param e

The exchange value

param n

The value to compare to v

return

initial value of the v

uint_fetch_and_add ( n : size_t ) size_t

fetch and increment atomically

Parameters
  • v – pointer of value to add to

  • n – data to add

Returns

original value in v

uint_fetch_and_and ( n : size_t ) size_t

fetch then bitwise AND atomically

Parameters
  • v – pointer of value to AND to

  • n – data to AND

Returns

the result

uint_fetch_and_nand ( n : size_t ) size_t

fetch then bitwise NAND atomically

Parameters
  • v – pointer of value to NAND to

  • n – data to NAND

Returns

the result

uint_fetch_and_or ( n : size_t ) size_t

fetch then bitwise OR atomically

Parameters
  • v – pointer of value to OR to

  • n – data to OR

Returns

the result

uint_fetch_and_sub ( n : size_t ) size_t

fetch and subtract atomically

Parameters
  • v – pointer of value to subtract from

  • n – data to subtract

Returns

original value in v

uint_fetch_and_xor ( n : size_t ) size_t

fetch then bitwise XOR atomically

Parameters
  • v – pointer of value to XOR to

  • n – data to XOR

Returns

the result

uint_get_and_set ( n : size_t ) size_t

get and set atomically

Parameters
  • v – pointer of value to get and set

  • n – value to set

Returns

original value

uint_nand_and_fetch ( n : size_t ) size_t

bitwise NAND and fetch the result atomically

Parameters
  • v – pointer of value to NAND to

  • n – data to NAND

Returns

resulted value

uint_or_and_fetch ( n : size_t ) size_t

bitwise XOR and fetch the result atomically

Parameters
  • v – pointer of value to OR to

  • n – data to OR

Returns

resulted value

uint_shift ( n : self_atomic_uint , r : self_atomic_uint )

value exchange between 3 pointers in 2 groups atomically, store n in v after store v in r

Parameters
  • v – pointer of v

  • n – pointer of n

  • r – pointer of r

Returns

None

uint_store ( n : self_atomic_uint )

Store value atomically

Parameters
  • v – the pointer to set

  • n – the pointer from value to set

Returns

None

uint_sub_and_fetch ( n : size_t ) size_t

sub and fetch atomically

:param self of value to subtract and get :param n: data to subtract :return: difference of the 2 values

uint_xor_and_fetch ( n : size_t ) size_t

bitwise XOR and fetch the result atomically

:param self of value to XOR to :param n: data to XOR :return: resulted value

property value : size_t

get and set the unsigned integer.