Bool and Float API: ¶
Module shared_atomic
-
bool type provide atomic operations, it takes 1 byte
- :attributes
-
reference: readonly pointer to the bool
value: read/write value of the bool
mode: readonly ‘s’ for single process, ‘m’ for multiprocessing
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 – whether the source code should be compatible with windows x64
-
-
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 – pointer of e
-
n – value to be set
-
- Returns
-
whether the contents of self and contents of e is the same
-
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
-
get and set atomically
- Parameters
-
n – value to set
- Returns
-
original value
-
value exchange between 3 atomic_bools in 2 groups atomically, store n in v after store v in r
- Parameters
-
-
v – atomic_bool v
-
n – atomic_bool n
-
r – atomic_bool r
-
- Returns
-
None
-
Store value atomically
- Parameters
-
n – another atomic_bool from which value to set
- Returns
-
None
-
getter
- Returns
-
bool value
-
setter
- Parameters
-
value – value to set
- Returns
-
None
-
get and set for the bool number.
-
float type provide atomic operations, it takes 8 bytes
- :attributes
-
reference: readonly pointer to the float
value: read/write value of the float
mode: readonly ‘s’ for single process, ‘m’ for multiprocessing, on windows platform, only singleprocessing is supported
constructor of atomic_float
- Parameters
-
-
value – initial value of atomic_float
-
mode – ‘s’ or ‘singleprocessing’ for single process, ‘m’ or ‘multiprocessing’ for multiprocessing
-
-
Store value atomically
- Parameters
-
n – another atomic_float from which value is from
- Returns
-
None
-
getter
- Returns
-
value
-
setter
- Parameters
-
value – value to set
- Returns
-
None
-
get and set for the float number.
-
calculate sha1(internally used) :return: calculated sha1