Procedure Oriented API:

Module shared_atomic.atomic_object on Linux and macOS

shared_atomic.atomic_object.array_add_and_fetch()

Increment and fetch atomically

Parameters
  • array – target array to change.

  • n – bytes will be added to the array.

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the contents of resulted bytearray

shared_atomic.atomic_object.array_and_and_fetch()

Bitwise and and then fetch atomically

Parameters
  • array – target array to change.

  • n – the other operands of AND operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_compare_and_set()

Compare and set atomically, this compares the contents of j with the contents of i. 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 j are written into i.

Parameters
  • i – the string to compare

  • j – the string to be compared with

  • data – another bytes to be ready to self if comparision return True

Returns

if self is equal to i return True, else return False

shared_atomic.atomic_object.array_compare_and_set_value()

Compare and set atomically,This compares the contents of self with the contents of i. 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 itself are written into i.

Parameters
  • array – target array to change.

  • i – The exchange value

  • n – The value to compare to

  • trim – whether the returned bytes should be trimmed of tailing b’\0’

Returns

Original value

shared_atomic.atomic_object.array_fetch_and_add()

fetch and increment atomically

Parameters
  • array – target array to change.

  • n – the bytes will be added to the array

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_and()

Fetch then bitwise AND atomically

Parameters
  • array – target array to change.

  • n – the other operands of AND operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_nand()

Fetch then bitwise NAND atomically

Parameters
  • array – target array to change.

  • n – the other operands of XOR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_or()

Fetch then bitwise OR atomically

Parameters
  • array – target array to change.

  • n – the other operands of OR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_sub()

fetch and decrement atomically

Parameters
  • array – target array to change.

  • n – the bytes will be substracted from the array

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_xor()

Fetch then bitwise XOR atomically

Parameters
  • array – target array to change.

  • n – the other operands of XOR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_get_and_set()

Get and set atomically

Parameters
  • array – target array to change.

  • data – new data

  • trim – if True, the leading b’\0’ would be trimmed, by default: True

Returns

the original bytes

shared_atomic.atomic_object.array_get_bytes()

Get all the bytes from the bytearray atomically

Parameters
  • array – target array.

  • trim – if True, the leading b’\0’ would be trimmed, by default: True

Returns

all the bytes in the bytearray

shared_atomic.atomic_object.array_get_int()

Get the integer representation from the bytearray, the whole array would be treated as a large integer

Parameters

array – target array.

Returns

the integer representation

shared_atomic.atomic_object.array_nand_and_fetch()

Bitwise nand and then fetch atomically

Parameters
  • array – target array to change.

  • n – the other operands of XOR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_or_and_fetch()

Bitwise or and then fetch atomically

Parameters
  • array – target array to change.

  • n – the other operands of OR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_set_bytes()

Set the bytes for the bytearray,

Parameters
  • array – target array.

  • data – bytes to set the data.

Returns

None

shared_atomic.atomic_object.array_shift()

Value exchange between 3 pointers 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_string

  • i – one atomic_string

  • j – another atomic_string

Returns

None

shared_atomic.atomic_object.array_store()

Set the bytes for the bytearray from another bytearray,

Parameters
  • n – target array.

  • i – source array.

Returns

None

shared_atomic.atomic_object.array_sub_and_fetch()

Decrement and fetch atomically

Parameters
  • array – target array to change.

  • n – bytes will be subtracted from the array.

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the contents of resulted bytearray

shared_atomic.atomic_object.array_xor_and_fetch()

Bitwise xor and then fetch atomically

Parameters
  • array – target array to change.

  • n – the other operands of XOR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.bool_compare_and_set()

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

shared_atomic.atomic_object.bool_compare_and_set_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

shared_atomic.atomic_object.bool_get()

get the contents of atomic_bool object atomically.

Parameters

boolean – atomic_bool object

Returns

the boolean value

shared_atomic.atomic_object.bool_get_and_set()

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

shared_atomic.atomic_object.bool_set()

set the contents of atomic_bool object atomically.

Parameters
  • boolean – atomic_bool object

  • n – the boolean value to set from

Returns

None

shared_atomic.atomic_object.bool_shift()

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

shared_atomic.atomic_object.bool_store()

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

shared_atomic.atomic_object.float_get()

get the contents of atomic_float object atomically.

Returns

the float value

shared_atomic.atomic_object.float_set()

set the contents of atomic_float object atomically.

Parameters
  • a – atomic_float object

  • n – the float value to set from

Returns

None

shared_atomic.atomic_object.float_store()

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

shared_atomic.atomic_object.int_add_and_fetch()

increment and fetch atomically

Parameters
  • integer – the atomic_int

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_object.int_and_and_fetch()

Bitwise AND and fetch atomically

Parameters
  • integer – the atomic_int

  • n – data to AND

Returns

the result value

shared_atomic.atomic_object.int_compare_and_set()

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

shared_atomic.atomic_object.int_compare_and_set_value()

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

shared_atomic.atomic_object.int_fetch_and_add()

increment and fetch atomically

Parameters
  • integer – the atomic_int

  • n – data to add

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_and()

fetch then bitwise AND atomically

Parameters
  • integer – the atomic_int

  • n – data to AND

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_nand()

fetch then bitwise NAND atomically

Parameters
  • integer – the atomic_int

  • n – data to NAND

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_or()

fetch then bitwise OR atomically

Parameters
  • integer – the atomic_int

  • n – data to OR

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_sub()

subtract and fetch atomically

Parameters
  • integer – the atomic_int

  • n – data to subtract

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_xor()

fetch then bitwise XOR atomically

Parameters
  • integer – the atomic_int

  • n – data to XOR

Returns

the initial value

shared_atomic.atomic_object.int_get()

get the contents of atomic_int atomically.

Parameters

integer – the atomic_int to get

Returns

the int value

shared_atomic.atomic_object.int_get_and_set()

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

shared_atomic.atomic_object.int_nand_and_fetch()

Bitwise NAND and fetch atomically

Parameters
  • integer – the atomic_int

  • n – data to NAND

Returns

the result value

shared_atomic.atomic_object.int_or_and_fetch()

Bitwise OR and fetch atomically

Parameters
  • integer – the atomic_int

  • n – data to OR

Returns

the result value

shared_atomic.atomic_object.int_set()

set the contents of atomic_int atomically.

Parameters
  • integer – the atomic_int to set

  • n – the integer value to set from

Returns

None

shared_atomic.atomic_object.int_shift()

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

shared_atomic.atomic_object.int_store()

Store value atomically.

Parameters
  • integer – the atomic_int to set

  • n – the atomic_int to set from

Returns

None

shared_atomic.atomic_object.int_sub_and_fetch()

sub and fetch atomically

Parameters
  • integer – the atomic_int

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_object.int_xor_and_fetch()

Bitwise XOR and fetch atomically

Parameters
  • integer – the atomic_int

  • n – data to XOR

Returns

the result value

shared_atomic.atomic_object.list_compare_and_set()

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
  • j – atomic_list object

  • i – atomic_list object

  • data – atomic_list object

Returns

if j is equal to i return True, else return False

shared_atomic.atomic_object.list_compare_and_set_value()

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

shared_atomic.atomic_object.list_get_and_set()

Get and set atomically

Parameters
  • input_list – target list.

  • data – new data list

Returns

the original list

shared_atomic.atomic_object.list_get_int()

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

shared_atomic.atomic_object.list_get_list()

Get the list atomically

Parameters

input_list – target list.

Returns

the list

shared_atomic.atomic_object.list_set_int()

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

shared_atomic.atomic_object.list_set_list()

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

shared_atomic.atomic_object.list_shift()

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

shared_atomic.atomic_object.list_store()

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

shared_atomic.atomic_object.set_compare_and_set()

Compare and set atomically. This compares the contents of atomic_set 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
  • j – atomic_set object

  • i – atomic_set object

  • data – atomic_set object

Returns

if j is equal to i return True, else return False

shared_atomic.atomic_object.set_compare_and_set_value()

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
  • intput_set – target set to change.

  • i – the value to set to

  • n – The value to be compared with

Returns

the original set

shared_atomic.atomic_object.set_get_and_set()

Get and set atomically

Parameters
  • intput_set – target set to change.

  • data – new data set

Returns

the original set

shared_atomic.atomic_object.set_get_int()

Get the whole integer representation from the set, the whole set would be treated as a large integer

Parameters

intput_set – target set.

Returns

the integer representation

shared_atomic.atomic_object.set_get_set()

Get the set atomically

Parameters

intput_set – target set.

Returns

the set

shared_atomic.atomic_object.set_set_int()

Set the whole integer representation from the set, the whole set would be treated as a large integer

Parameters
  • intput_set – target set to change.

  • integer – integer representation of the new value.

Returns

None

shared_atomic.atomic_object.set_set_set()

Set the value in the set, if the new data is longer than the original size of the set. it will expand the set accordingly which would lose atomicity. the size of the set can be checked with set.size

Parameters
  • intput_set – target set to change.

  • data – input set

Returns

None

shared_atomic.atomic_object.set_shift()

Value exchange between 3 pointers 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_set

  • i – one atomic_set

  • j – one atomic_set

Returns

None

shared_atomic.atomic_object.set_store()

Atomically store contents from another set to this set, 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_set to set

  • i – the atomic_set to set from

Returns

None

shared_atomic.atomic_object.shared_memory_offset_add_and_fetch()

increment and fetch atomically

Parameters
  • value – data to add

  • offset – the offset inside the shared memory starting from 0 you need to add,

Returns

sum of the 2 values

shared_atomic.atomic_object.shared_memory_offset_and_and_fetch()

bitwise AND and fetch the result atomically

Parameters
  • value – data to AND

  • offset – the offset inside the shared memory starting from 0 you need to AND with,

Returns

the result value

shared_atomic.atomic_object.shared_memory_offset_compare_and_set()

Compare and set atomically. This compares the contents of shared_memory2 at offset2 with the contents of memory at offset. If equal, the operation is a read-modify-write operation that writes bytes parameter value into self. If they are not equal, the operation is a read and the current contents of memory are written into shared_memory2.

Parameters
  • memory – target shared memory.

  • shared_memory2 – the other shared memory from which the data is from

  • value – the value to write to the shared memory,

  • offset – the offset inside the shared memory starting from 0 you need to set,

  • offset2 – the offset2 inside the shared memory 2 starting from 0 you need to get,

Returns

whether the contents of memory and contents of shared_memory2 is the same

shared_atomic.atomic_object.shared_memory_offset_compare_and_set_value()

Compare and set atomically. This compares the contents of n with the contents of memory at offset. If equal, the operation is a read-modify-write operation that writes bytes parameter value into memory. If they are not equal, no operation will be taken.

Parameters
  • i – exchange value

  • n – The value to be compared with

  • offset – the offset inside the shared memory starting from 0 you need to set,

Returns

the original value at offset

shared_atomic.atomic_object.shared_memory_offset_compare_with_other_type_and_set()

Compare and set atomically. This compares the contents of another atomic_object with the contents of memory at offset. If equal, the operation is a read-modify-write operation that writes bytes parameter value into memory. If they are not equal, the operation is a read and the current contents of self are written into object2.

Parameters
  • memory – target shared memory.

  • object2 – the other atomic object from which the data is compared with

  • offset – the offset inside the shared memory starting from 0 you need to compare and set,

  • value – value to be set

Returns

whether the contents of memory and contents of object2 is the same

shared_atomic.atomic_object.shared_memory_offset_fetch_and_add()

fetch and increment atomically

Parameters
  • value – data to add

  • offset – the offset inside the shared memory starting from 0 you need to add to,

Returns

original value

shared_atomic.atomic_object.shared_memory_offset_fetch_and_and()

fetch then bitwise AND atomically

Parameters
  • value – value to AND to

  • offset – the offset inside the shared memory starting from 0 you need to AND to,

Returns

original value

shared_atomic.atomic_object.shared_memory_offset_fetch_and_nand()

fetch then bitwise NAND atomically

Parameters
  • value – value to NAND with

  • offset – the offset inside the shared memory starting from 0 you need to NAND with,

Returns

original value

shared_atomic.atomic_object.shared_memory_offset_fetch_and_or()

fetch then bitwise OR atomically

Parameters
  • value – value to OR with

  • offset – the offset inside the shared memory starting from 0 you need to OR with,

Returns

original value

shared_atomic.atomic_object.shared_memory_offset_fetch_and_sub()

fetch and substract atomically

Parameters
  • value – data to sub

  • offset – the offset inside the shared memory starting from 0 you need to substract from,

Returns

original value

shared_atomic.atomic_object.shared_memory_offset_fetch_and_xor()

fetch then bitwise XOR atomically

Parameters
  • value – value to XOR with

  • offset – the offset inside the shared memory starting from 0 you need to XOR with,

Returns

original value

shared_atomic.atomic_object.shared_memory_offset_get()

Atomically get the bytes at specific offset given specific length

Parameters
  • memory – target shared memory.

  • offset – the offset inside the shared memory starting from 0

  • length – the length of bytes should be retrieved

Returns

bytes at specific offset.

shared_atomic.atomic_object.shared_memory_offset_get_and_set()

Atomically set the bytes at specific offset given specific length

Parameters
  • memory – target shared memory.

  • value – new value in bytes

  • offset – the offset inside the shared memory starting from 0, including the operation length

Returns

bytes at specific offset previously.

shared_atomic.atomic_object.shared_memory_offset_nand_and_fetch()

bitwise NAND and fetch the result atomically

Parameters
  • value – data to NAND

  • offset – the offset inside the shared memory starting from 0 you need to NAND with,

Returns

the result value

shared_atomic.atomic_object.shared_memory_offset_or_and_fetch()

bitwise OR and fetch the result atomically

Parameters
  • value – data to OR

  • offset – the offset inside the shared memory starting from 0 you need to OR with,

Returns

the result value

shared_atomic.atomic_object.shared_memory_offset_store()

Atomically set the data at specific offset given specific length

Parameters
  • memory – target shared memory.

  • shared_memory2 – the other shared memory from which the data is from

  • offset – the offset inside the shared memory starting from 0 you need to set,

  • offset2 – the offset inside the shared memory from the data you want,

  • length – the length of bytes should be set in the shared memory and get the data from the shared memory 2, only 1,2,4 and 8 are supported

Returns

None

shared_atomic.atomic_object.shared_memory_offset_store_from_other_types()

Atomically set the data at specific offset given specific length, if object2 is in variable length, and object2 is changing the size at the same time, the method will not be atomic, otherwise, the operation is atomic.

Parameters
  • memory – target shared memory.

  • object2 – the other atomic object from which the data is from

  • offset – the offset inside the shared memory starting from 0 you need to set

Returns

None

shared_atomic.atomic_object.shared_memory_offset_sub_and_fetch()

increment and fetch atomically

Parameters
  • value – data to sub

  • offset – the offset inside the shared memory starting from 0 you need to add,

Returns

sum of the 2 values

shared_atomic.atomic_object.shared_memory_offset_xor_and_fetch()

bitwise XOR and fetch the result atomically

Parameters
  • value – data to XOR

  • offset – the offset inside the shared memory starting from 0 you need to XOR with,

Returns

the result value

shared_atomic.atomic_object.string_compare_and_set()

Compare and set atomically, this compares the contents of j with the contents of i. If equal, the operation is a read-modify-write operation that writes n into j. If they are not equal, the operation is a read and the current contents of j are written into i.

Parameters
  • j – the string to be compared

  • i – the string to be compared with

  • n – another string to be write to j if comparision return True

Returns

if j is equal to n return True, else return False

shared_atomic.atomic_object.string_compare_and_set_value()

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

Parameters
  • string – target string.

  • i – The exchange value

  • n – the value to be compared with

Returns

the original string

shared_atomic.atomic_object.string_get_and_set()

Get and set atomically

Parameters
  • string – target string.

  • data – new data

Returns

the original string

shared_atomic.atomic_object.string_get_string()

Get all the bytes from the string atomically

Parameters

string – target string.

Returns

the full string

shared_atomic.atomic_object.string_set_string()

Set the bytes value in the string, if the new data is longer than the original size of the string. it will expand the string accordingly which would lose atomicity. the size of the string can be check with self.size

Parameters
  • string – target string.

  • data – value to set to

Returns

None

shared_atomic.atomic_object.string_shift()

Value exchange between 3 atomic_strings 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_string

  • i – one atomic_string

  • j – another atomic_string

Returns

None

shared_atomic.atomic_object.string_store()

Atomically set the data in atomic_string n from atomic_string i

Parameters
  • n – target atomic_string.

  • i – atomic_string from which the data is from

Returns

None

shared_atomic.atomic_object.uint_add_and_fetch()

increment and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_object.uint_and_and_fetch()

Bitwise AND and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to AND

Returns

the result value

shared_atomic.atomic_object.uint_compare_and_set()

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_uint object

  • e – atomic_uint object

  • n – the integer value to set from

Returns

if integer is equal to e return True, else return False

shared_atomic.atomic_object.uint_compare_and_set_value()

Compare and swap atomically, This compares the contents of atomic_uint 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_uint

  • e – the integer value

  • n – the integer value

Returns

the initial value

shared_atomic.atomic_object.uint_fetch_and_add()

increment and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to add

Returns

the initial value

shared_atomic.atomic_object.uint_fetch_and_and()

fetch then bitwise AND atomically

Parameters
  • integer – the atomic_uint

  • n – data to AND

Returns

the initial value

shared_atomic.atomic_object.uint_fetch_and_nand()

fetch then bitwise NAND atomically

Parameters
  • integer – the atomic_uint

  • n – data to NAND

Returns

the initial value

shared_atomic.atomic_object.uint_fetch_and_or()

fetch then bitwise OR atomically

Parameters
  • integer – the atomic_uint

  • n – data to OR

Returns

the initial value

shared_atomic.atomic_object.uint_fetch_and_sub()

subtract and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to subtract

Returns

the initial value

shared_atomic.atomic_object.uint_fetch_and_xor()

fetch then bitwise XOR atomically

Parameters
  • integer – the atomic_uint

  • n – data to XOR

Returns

the initial value

shared_atomic.atomic_object.uint_get()

get the contents of atomic_uint atomically.

Parameters

integer – the atomic_uint to get

Returns

the int value

shared_atomic.atomic_object.uint_get_and_set()

get and set contents of atomic_uint atomically.

Parameters
  • integer – the atomic_uint

  • n – the integer value to set from

Returns

the original int value

shared_atomic.atomic_object.uint_nand_and_fetch()

Bitwise NAND and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to NAND

Returns

the result value

shared_atomic.atomic_object.uint_or_and_fetch()

Bitwise OR and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to OR

Returns

the result value

shared_atomic.atomic_object.uint_set()

set the contents of atomic_uint atomically.

Parameters
  • integer – the atomic_uint to set

  • n – the integer value to set from

Returns

None

shared_atomic.atomic_object.uint_shift()

value exchange between 3 atomic_uint in 2 groups atomically, store n in integer after store integer in r.

Parameters
  • integer – the atomic_uint integer

  • n – the atomic_uint n

  • r – the atomic_uint r

Returns

None

shared_atomic.atomic_object.uint_store()

Store value atomically.

Parameters
  • integer – the atomic_uint to set

  • n – the atomic_uint to set from

Returns

None

shared_atomic.atomic_object.uint_sub_and_fetch()

sub and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_object.uint_xor_and_fetch()

Bitwise XOR and fetch atomically

Parameters
  • integer – the atomic_uint

  • n – data to XOR

Returns

the result value

On Microsoft Windows

shared_atomic.atomic_object.array_add_and_fetch()

Increment and fetch atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • n – bytes will be added to the array.

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the contents of resulted bytearray

shared_atomic.atomic_object.array_bittest_and_reset()

bittest_and_reset the original contents in the bytearray

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • offset – offset from counted by bits from the left.

Returns

original value(True or False) at the offset

shared_atomic.atomic_object.array_bittest_and_set()

bittest_and_set the original contents in the bytearray

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • offset – offset from counted by bits from the left.

Returns

original value(True or False) at the offset

shared_atomic.atomic_object.array_compare_and_set_value()

Compare and set atomically,This compares the contents of self with the contents of i. 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 itself are written into i.

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • i – The exchange value

  • n – The value to compare to

  • trim – whether the returned bytes should be trimmed of tailing b’

shared_atomic.atomic_object.array_fetch_and_add()

fetch and increment atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • n – the bytes will be added to the array

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_and()

Fetch then bitwise AND atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • n – the other operands of AND operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_or()

Fetch then bitwise OR atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • n – the other operands of OR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_sub()

fetch and decrement atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • n – the bytes will be substracted from the array

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_fetch_and_xor()

Fetch then bitwise XOR atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • n – the other operands of XOR operation

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the original contents of the bytearray

shared_atomic.atomic_object.array_get_and_set()

Get and set atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • data – new data

  • trim – if True, the leading b’\0’ would be trimmed, by default: True

Returns

the original bytes

shared_atomic.atomic_object.array_get_bytes()

Get all the bytes from the bytearray atomically

Parameters
  • array – target array.

  • reference – reference got by the subprocess .

  • trim – if True, the leading b’\0’ would be trimmed, by default: True

Returns

all the bytes in the bytearray

shared_atomic.atomic_object.array_get_int()

Get the integer representation from the bytearray, the whole array would be treated as a large integer

Parameters
  • array – target array.

  • reference – reference got by the subprocess .

Returns

the integer representation

shared_atomic.atomic_object.array_set_bytes()

Set the bytes for the bytearray,

Parameters
  • array – target array.

  • reference – reference got by the subprocess.

  • data – bytes to set the data.

Returns

None

shared_atomic.atomic_object.array_sub_and_fetch()

Decrement and fetch atomically

Parameters
  • array – target array to change.

  • reference – reference got by the subprocess.

  • n – bytes will be subtracted from the array.

  • trim – whether of not to trim the returning b’\0’ when fetch, default True

Returns

the contents of resulted bytearray

shared_atomic.atomic_object.bool_compare_and_set_value()

Compare and swap atomically, This compares the contents of subprocess reference 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
  • reference – the reference used in subprocess

  • e – The exchange value

  • n – the value to be compared with

Returns

the initial value

shared_atomic.atomic_object.bool_get()

get the contents of subprocess reference atomically.

Parameters

reference – the reference used in subprocess

Returns

the boolean value

shared_atomic.atomic_object.bool_get_and_set()

get and set contents of subprocess reference atomically.

Parameters
  • reference – the reference used in subprocess

  • n – the boolean value to set from

Returns

the original boolean value

shared_atomic.atomic_object.bool_set()

set the contents of subprocess reference atomically.

Parameters
  • reference – the reference used in subprocess

  • n – the boolean value to set from

Returns

None

shared_atomic.atomic_object.get_reference()

get reference from the shared atomic_object in multiprocessing imcompatible mode.

Parameters

a – the atomic_object to get the reference from

Returns

subprocess_reference can be used in subprocesses

shared_atomic.atomic_object.int_add_and_fetch()

increment and fetch atomically

Parameters
  • reference – the reference used in subprocess

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_object.int_bittest_and_reset()

Tests the specified bit and set it to 0 atomically

Parameters
  • reference – the reference used in subprocess

  • offset – offset in the binary presenation of the 64bit integer

Returns

the initial value(True or False) of specified bit

shared_atomic.atomic_object.int_bittest_and_set()

fetch then bitwise NAND atomically

Parameters
  • reference – the reference used in subprocess

  • offset – offset in the binary presenation of the 64bit integer

Returns

the initial value(True or False) of specified bit

shared_atomic.atomic_object.int_compare_and_set_value()

Compare and swap atomically, This compares the contents of subprocess reference 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
  • reference – the reference used in subprocess

  • e – the integer value

  • n – the integer value

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_add()

increment and fetch atomically

Parameters
  • reference – the reference used in subprocess

  • n – data to add

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_and()

fetch then bitwise AND atomically

Parameters
  • reference – the reference used in subprocess

  • n – data to AND

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_or()

fetch then bitwise OR atomically

Parameters
  • reference – the reference used in subprocess

  • n – data to OR

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_sub()

subtract and fetch atomically

Parameters
  • reference – the reference used in subprocess

  • n – data to subtract

Returns

the initial value

shared_atomic.atomic_object.int_fetch_and_xor()

fetch then bitwise XOR atomically

Parameters
  • reference – the reference used in subprocess

  • n – data to XOR

Returns

the initial value

shared_atomic.atomic_object.int_get()

get the contents of subprocess reference atomically.

Parameters

reference – the reference used in subprocess

Returns

the int value

shared_atomic.atomic_object.int_get_and_set()

get and set contents of subprocess reference atomically.

Parameters
  • reference – the reference used in subprocess

  • n – the integer value to set from

Returns

the original int value

shared_atomic.atomic_object.int_set()

set the contents of subprocess reference atomically.

Parameters
  • reference – the reference used in subprocess

  • n – the integer value to set from

Returns

None

shared_atomic.atomic_object.int_sub_and_fetch()

sub and fetch atomically

Parameters
  • reference – the reference used in subprocess

  • n – the integer value

Returns

sum of the 2 values

shared_atomic.atomic_object.list_compare_and_set_value()

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

shared_atomic.atomic_object.list_get_and_set()

Get and set atomically

Parameters
  • input_list – target list.

  • reference – the reference used in subprocess

  • data – new data list

Returns

the original list

shared_atomic.atomic_object.list_get_int()

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

shared_atomic.atomic_object.list_get_list()

Get the list atomically

Parameters
  • input_list – target list.

  • reference – the reference used in subprocess

Returns

the list

shared_atomic.atomic_object.list_set_int()

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

shared_atomic.atomic_object.list_set_list()

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

shared_atomic.atomic_object.release_reference()

release the reference got by get_reference.

Parameters

a – the subprocess reference to release

Returns

None

shared_atomic.atomic_object.set_compare_and_set_value()

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
  • intput_set – target set to change.

  • reference – the reference used in subprocess

  • i – the value to set to

  • n – The value to be compared with

Returns

the original set

shared_atomic.atomic_object.set_get_and_set()

Get and set atomically

Parameters
  • intput_set – target set to change.

  • reference – the reference used in subprocess

  • data – new data set

Returns

the original set

shared_atomic.atomic_object.set_get_int()

Get the whole integer representation from the set, the whole set would be treated as a large integer

Parameters
  • intput_set – target set.

  • reference – the reference used in subprocess

Returns

the integer representation

shared_atomic.atomic_object.set_get_set()

Get the set atomically

Parameters
  • intput_set – target set.

  • reference – the reference used in subprocess

Returns

the set

shared_atomic.atomic_object.set_set_int()

Set the whole integer representation from the set, the whole set would be treated as a large integer

Parameters
  • intput_set – target set.

  • reference – the reference used in subprocess

  • integer – integer representation of the new value.

Returns

None

shared_atomic.atomic_object.set_set_set()

Set the value in the set, if the new data is longer than the original size of the set. it will expand the set accordingly which would lose atomicity. the size of the set can be checked with set.size

Parameters
  • intput_set – target set to change.

  • reference – the reference used in subprocess

  • data – input set

Returns

None

shared_atomic.atomic_object.shared_memory_offset_add_and_fetch()

increment and fetch atomically

Parameters
  • memory – target shared memory.

  • reference – the reference used in subprocess

  • value – data to add

  • offset – the offset inside the shared memory starting from 0

Returns

sum of the 2 values

shared_atomic.atomic_object.shared_memory_offset_bittest_and_reset()

test and reset the bit at offset atomically

Parameters
  • memory – target shared memory to change.

  • reference – the reference used in subprocess

  • left_offset – the offset inside the shared memory starting from 0

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_bittest_and_set()

test and set the bit at offset atomically

Parameters
  • memory – target shared memory to change.

  • reference – the reference used in subprocess

  • left_offset – the offset inside the shared memory starting from 0,

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_compare_and_set_value()

Compare and set atomically. This compares the contents of pointer with the contents of self at offset. If equal, the operation is a read-modify-write operation that writes bytes parameter value into self. If they are not equal, the operation is a read and the current contents of self are written into pointer.

Parameters
  • memory – target shared memory.

  • reference – the reference used in subprocess

  • i – the value to set

  • n – the value to be compared with

  • offset – the offset inside the shared memory starting from 0 you need to compare and set,

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_fetch_and_add()

fetch and increment atomically

Parameters
  • memory – target shared memory to change.

  • reference – the reference used in subprocess

  • value – data to add

  • offset – the offset inside the shared memory starting from 0

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_fetch_and_and()

fetch and and atomically

Parameters
  • memory – target shared memory to change.

  • reference – the reference used in subprocess

  • value – data to and

  • offset – the offset inside the shared memory starting from 0

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_fetch_and_or()

fetch and or atomically

Parameters
  • memory – target shared memory to change.

  • reference – the reference used in subprocess

  • value – data to or

  • offset – the offset inside the shared memory starting from 0

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_fetch_and_sub()

fetch and substract atomically

Parameters
  • memory – target shared memory to change.

  • reference – the reference used in subprocess

  • value – data to substract

  • offset – the offset inside the shared memory starting from 0

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_fetch_and_xor()

fetch and xor atomically

Parameters
  • memory – target shared memory to change.

  • reference – the reference used in subprocess

  • value – data to xor

  • offset – the offset inside the shared memory starting from 0

Returns

the initial value at the offset of memory

shared_atomic.atomic_object.shared_memory_offset_get()

Atomically get the bytes at specific offset given specific length

Parameters
  • memory – target shared memory.

  • reference – the reference used in subprocess

  • offset – the offset inside the shared memory starting from 0

  • length – the length of bytes should be retrieved

Returns

bytes at specific offset.

shared_atomic.atomic_object.shared_memory_offset_get_and_set()

Atomically set the bytes at specific offset an get the original value

Parameters
  • memory – target shared memory.

  • reference – the reference used in subprocess

  • value – new value in bytes

  • offset – the offset inside the shared memory starting from 0

Returns

bytes at specific offset previously.

shared_atomic.atomic_object.shared_memory_offset_sub_and_fetch()

substract and fetch atomically

Parameters
  • memory – target shared memory.

  • reference – the reference used in subprocess

  • value – data to substract

  • offset – the offset inside the shared memory starting from 0

Returns

difference of the 2 values

shared_atomic.atomic_object.string_compare_and_set_value()

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

Parameters
  • string – target string.

  • reference – the reference used in subprocess.

  • i – The exchange value

  • n – the value to be compared with

Returns

the original string

shared_atomic.atomic_object.string_get_and_set()

Get and set atomically

Parameters
  • string – target string.

  • reference – the reference used in subprocess.

  • data – new data

Returns

the original string

shared_atomic.atomic_object.string_get_string()

Get all the bytes from the string atomically

Parameters
  • string – target string.

  • reference – the reference used in subprocess

Returns

the full string

shared_atomic.atomic_object.string_set_string()

Set the bytes value in the string, if the new data is longer than the original size of the string. it will expand the string accordingly which would lose atomicity. the size of the string can be check with self.size

Parameters
  • string – target string.

  • reference – the reference used in subprocess.

  • data – value to set to

Returns

None

class shared_atomic.atomic_object.subprocess_reference

class of subprocess references generated for multiprocessing mode

initialize the class.

Parameters
  • file_mapping – the file mapping handle

  • reference – the pointer used

Returns

subprocess_reference