Bool and Float API:¶
Module shared_atomic.atomic_boolfloat on Linux and macOS
bool type provide atomic operations, it takes 1 bytes
- :attributes
value: used to get and set the value atomically
constructor of atomic_bool
- Parameters
value – initial value of atomic_bool
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
Compare and set atomically. This compares the contents of self with the contents of b. 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 b.
- Parameters
b – atomic_bool object
n – the boolean value to set from
- Returns
the original boolean 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 n into self. If they are not equal, no operation will be taken.
- Parameters
e – the value to set from
n – the value to compare to
- Returns
None
get and set atomically
- Parameters
n – value to set
- Returns
None
value exchange between 3 atomic_bools in 2 groups atomically, store b in self after store self in c
- Parameters
b – atomic_bool object
c – atomic_bool object
- Returns
None
set the contents of atomic_bool object self atomically from another atomic_bool object b
- Parameters
b – atomic_bool object
- Returns
None
get the bool value from the atomic_bool :return: value
set the bool value from the atomic_bool
- Parameters
value – value to set
- Returns
None
float type provide atomic operations, it takes 8 bytes, for unix platforms only.
- :attributes
value: used to get and set the value atomically
constructor of atomic_float
- Parameters
value – initial value of atomic_float
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
set the contents of atomic_bool object self atomically from another atomic_float object n
- Parameters
n – atomic_float object
- Returns
None
get the contents of atomic_float object atomically.
- Returns
the float value
set the contents of atomic_float object atomically.
- Parameters
value – the float value to set from
- Returns
None
Compare and set atomically. This compares the contents of a with the contents of b. 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 a are written into b.
- Parameters
a – atomic_bool object
b – atomic_bool object
n – the boolean value to set from
- Returns
the original boolean value
Compare and swap atomically, This compares the contents of atomic_bool object a 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 is performed.
- Parameters
a – the atomic_bool object
e – The exchange value
n – the value to be compared with
- Returns
the initial value
get the contents of atomic_bool object atomically.
- Parameters
boolean – atomic_bool object
- Returns
the boolean value
get and set contents of atomic_bool object atomically.
- Parameters
a – atomic_bool object
n – the boolean value to set from
- Returns
the original boolean value
set the contents of atomic_bool object atomically.
- Parameters
boolean – atomic_bool object
n – the boolean value to set from
- Returns
None
value exchange between 3 atomic_bools in 2 groups atomically, store b in a after store a in n
- Parameters
a – atomic_bool object
b – atomic_bool object
n – atomic_bool object
- Returns
None
set the contents of atomic_bool object a atomically from another atomic_bool object b
- Parameters
a – atomic_bool object
b – atomic_bool object
- Returns
None
get the contents of atomic_float object atomically.
- Parameters
a – atomic_float object
- Returns
the float value
set the contents of atomic_float object atomically.
- Parameters
a – atomic_float object
n – the float value to set from
- Returns
None
set the contents of atomic_float object a atomically from another atomic_float object b
- Parameters
v – atomic_float object
n – atomic_float object
- Returns
None