Int API:¶
Module shared_atomic.atomic_int on Linux and macOS
int provide atomic operations, the int takes 8 bytes
- :attributes
value: read/write value of the integer
constructor of atomic_int
- 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 the contents of atomic_int atomically.
- Returns
the int value
increment and fetch atomically
- Parameters
n – data to add
- Returns
sum of the 2 values
bitwise AND and fetch the result atomically
- Parameters
n – data to AND
- Returns
the result value
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_int object
n – the integer value to set from
- Returns
if self is equal to e return True, else return False
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
fetch and increment atomically
- Parameters
n – data to add
- Returns
the original value
fetch then bitwise AND atomically
- Parameters
n – data to AND
- Returns
the original value
fetch then bitwise NAND atomically
- Parameters
n – data to NAND
- Returns
the original value
fetch then bitwise OR atomically
- Parameters
n – data to OR
- Returns
the original value
fetch and subtract atomically
- Parameters
n – data to subtract
- Returns
the original value
fetch then bitwise XOR atomically
- Parameters
n – data to XOR
- Returns
the original value
get and set contents of atomic_int atomically.
- Parameters
n – the integer value to set from
- Returns
the original int value
bitwise NAND and fetch the result atomically
- Parameters
n – data to NAND
- Returns
the result value
bitwise XOR and fetch the result atomically
- Parameters
n – data to OR
- Returns
the result value
value exchange between 3 atomic_ints in 2 groups atomically, store n in self after store self in r.
- Parameters
n – the atomic_int n
r – the atomic_int r
- Returns
None
Store value atomically.
- Parameters
n – the atomic_int to set from
- Returns
None
sub and fetch atomically
- Parameters
n – data to subtract
- Returns
difference of the 2 values
bitwise XOR and fetch the result atomically
- Parameters
n – data to XOR
- Returns
the result value
set the contents of atomic_int atomically.
- Parameters
value – the integer value to set from
- Returns
None
increment and fetch atomically
- Parameters
integer – the atomic_int
n – the integer value
- Returns
sum of the 2 values
Bitwise AND and fetch atomically
- Parameters
integer – the atomic_int
n – data to AND
- Returns
the result value
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_int object
e – atomic_int object
n – the integer value to set from
- Returns
if integer is equal to e return True, else return False
Compare and swap atomically, This compares the contents of atomic_int 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_int
e – the integer value
n – the integer value
- Returns
the initial value
increment and fetch atomically
- Parameters
integer – the atomic_int
n – data to add
- Returns
the initial value
fetch then bitwise AND atomically
- Parameters
integer – the atomic_int
n – data to AND
- Returns
the initial value
fetch then bitwise NAND atomically
- Parameters
integer – the atomic_int
n – data to NAND
- Returns
the initial value
fetch then bitwise OR atomically
- Parameters
integer – the atomic_int
n – data to OR
- Returns
the initial value
subtract and fetch atomically
- Parameters
integer – the atomic_int
n – data to subtract
- Returns
the initial value
fetch then bitwise XOR atomically
- Parameters
integer – the atomic_int
n – data to XOR
- Returns
the initial value
get the contents of atomic_int atomically.
- Parameters
integer – the atomic_int to get
- Returns
the int value
get and set contents of atomic_int atomically.
- Parameters
integer – the atomic_int
n – the integer value to set from
- Returns
the original int value
Bitwise NAND and fetch atomically
- Parameters
integer – the atomic_int
n – data to NAND
- Returns
the result value
Bitwise OR and fetch atomically
- Parameters
integer – the atomic_int
n – data to OR
- Returns
the result value
set the contents of atomic_int atomically.
- Parameters
integer – the atomic_int to set
n – the integer value to set from
- Returns
None
value exchange between 3 atomic_ints in 2 groups atomically, store n in integer after store integer in r.
- Parameters
integer – the atomic_int integer
n – the atomic_int n
r – the atomic_int r
- Returns
None
Store value atomically.
- Parameters
integer – the atomic_int to set
n – the atomic_int to set from
- Returns
None
sub and fetch atomically
- Parameters
integer – the atomic_int
n – the integer value
- Returns
sum of the 2 values
Bitwise XOR and fetch atomically
- Parameters
integer – the atomic_int
n – data to XOR
- Returns
the result value