List API:¶
Module shared_atomic.atomic_list on Linux and macOS
List provide atomic operations, the list should be no longer than 8 bytes
- :attributes
encoding: readonly string character set
initial_length: readonly total length in bits
value: used to get and set the value atomically
int_value: readonly properties to get the integer representation of the list
constructor to initialize the set, the set should be no longer than 8 bytes
- Parameters
initial – initial value of the set, if the initial value is longer than 8 bytes, please specify the trimming target length, or else it would fail.n
encoding – , character set, default ‘utf-8’n
mode – the mode in which the set will be shared. ‘singleprocessing’ or ‘s’ for single process, ‘multiprocessing’ or ‘m’ for multiprocessing.n
windows_unix_compatibility – whether the source code should be compatible with unix platform.
Get the whole integer representation from the list, the whole list would be treated as a large integer
- Returns
the integer representation
Get the list atomically
- Returns
the list
Compare and set atomically. This compares the contents of self with the contents of j. 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 i.
- Parameters
j – atomic_list object
data – the list to set from
- Returns
if self is equal to j return True, else return False
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.
- Parameters
i – the value to set from
n – the value to be compared with
- Returns
the initial value
Get and set atomically
- Parameters
data – new data to set
- Returns
the original list
Value exchange between 3 atomic_list in 2 groups atomically, the initial_length field will be updated but not atomically. store i in self after store self in j
- Parameters
i – one atomic_list
j – one atomic_list
- Returns
None
Store value atomically.
- Parameters
i – the atomic_list to set from
- Returns
None
Change the encoding of the list, if the original size is not enough, it will elongate the list, if 8 bytes are not enough, it will fail.
- Parameters
newencode – new encoding, such as ‘utf-8’, ‘utf-16-le’
- Returns
None
Set the whole integer representation from the set, the whole list would be treated as a large integer
- Parameters
integer – integer representation of the value to set to
- Returns
None
Set the value in the list, if the new data is longer than the original size of the list. it will expand the set accordingly which would lose atomicity. the size of the set can be checked with self.size
- Parameters
data – input list
- Returns
None
Compare and set atomically. This compares the contents of atomic_list j with the contents of i. If equal, the operation is a read-modify-write operation that writes data into integer. If they are not equal, the operation is a read and the current contents of j are written into i.
- Parameters
input_list – target list.
j – atomic_list object
i – atomic_list object
data – atomic_list object
- Returns
if j is equal to i return True, else return False
Compare and set atomically,This compares the contents of input_list with the contents of i. If equal, the operation is a read-modify-write operation that writes n into input_list. If they are not equal, no action will be taken.
- Parameters
input_list – target list.
i – The exchange value
n – The value to compare to
- Returns
Original value
Get and set atomically
- Parameters
input_list – target list.
data – new data list
- Returns
the original list
Get the whole integer representation from the list, the whole set would be treated as a large integer
- Parameters
input_list – target list.
- Returns
the integer representation
Get the list atomically
- Parameters
input_list – target list.
- Returns
the list
Set the whole integer representation from the set, the whole set would be treated as a large integer
- Parameters
input_list – target list.
- Returns
None
Set the value in the list, if the new data is longer than the original size of the list. it will expand the set accordingly which would lose atomicity. the size of the set can be checked with list.size
- Parameters
input_list – target list.
data – input list
- Returns
None
Value exchange between 3 atomic_list in 2 groups atomically, the initial_length field will be updated but not atomically. store i in n after store n in j
- Parameters
n – one atomic_list
i – one atomic_list
j – one atomic_list
- Returns
None
Atomically store contents from another list to this list, if the other set is different with this one in size , or the other set is different with this one in encoding , the function will fail.
- Parameters
n – the atomic_list to set
i – the atomic_list to set from
- Returns
None
On Microsoft Windows
List provide atomic operations, the list should be no longer than 8 bytes
- :attributes
encoding: readonly string character set
initial_length: readonly total length in bits
value: used to get and set the value atomically
int_value: readonly properties to get the integer representation of the list
constructor to initialize the set, the set should be no longer than 8 bytes
- Parameters
initial – initial value of the set, if the initial value is longer than 8 bytes, please specify the trimming target length, or else it would fail.n
encoding – , character set, default ‘utf-8’n
mode – the mode in which the set will be shared. ‘singleprocessing’ or ‘s’ for single process, ‘multiprocessing’ or ‘m’ for multiprocessing.n
windows_unix_compatibility – whether the source code should be compatible with unix platform.
Get the whole integer representation from the list, the whole list would be treated as a large integer
- Returns
the integer representation
Get the list atomically
- Returns
the list
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.
- Parameters
i – the value to set from
n – the value to be compared with
- Returns
the initial value
Get and set atomically
- Parameters
data – new data to set
- Returns
the original list
Change the encoding of the list, if the original size is not enough, it will elongate the list, if 8 bytes are not enough, it will fail.
- Parameters
newencode – new encoding, such as ‘utf-8’, ‘utf-16-le’
- Returns
None
Set the whole integer representation from the set, the whole list would be treated as a large integer
- Parameters
integer – integer representation of the value to set to
- Returns
None
Set the value in the list, if the new data is longer than the original size of the list. it will expand the set accordingly which would lose atomicity. the size of the set can be checked with self.size
- Parameters
data – input list
- Returns
None
Compare and set atomically,This compares the contents of input_list with the contents of n. If equal, the operation is a read-modify-write operation that writes i into input_list. If they are not equal, no action will be taken.
- Parameters
input_list – target list.
reference – the reference used in subprocess
i – The exchange value
n – The value to compare to
- Returns
Original value
Get and set atomically
- Parameters
input_list – target list.
reference – the reference used in subprocess
data – new data list
- Returns
the original list
Get the whole integer representation from the list, the whole set would be treated as a large integer
- Parameters
input_list – target list.
reference – the reference used in subprocess
- Returns
the integer representation
Get the list atomically
- Parameters
input_list – target list.
reference – the reference used in subprocess
- Returns
the list
Set the whole integer representation from the set, the whole set would be treated as a large integer
- Parameters
input_list – target list.
reference – the reference used in subprocess
- Returns
None
Set the value in the list, if the new data is longer than the original size of the list. it will expand the set accordingly which would lose atomicity. the size of the set can be checked with list.size
- Parameters
input_list – target list.
reference – the reference used in subprocess
data – input list
- Returns
None