Bool and Float API:

Module shared_atomic.atomic_boolfloat on Linux and macOS

class shared_atomic.atomic_boolfloat.atomic_bool

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

bool_compare_and_set()

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

bool_compare_and_set_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

bool_get_and_set()

get and set atomically

Parameters

n – value to set

Returns

None

bool_shift()

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

bool_store()

set the contents of atomic_bool object self atomically from another atomic_bool object b

Parameters

b – atomic_bool object

Returns

None

get()

get the bool value from the atomic_bool :return: value

set()

set the bool value from the atomic_bool

Parameters

value – value to set

Returns

None

class shared_atomic.atomic_boolfloat.atomic_float

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

float_store()

set the contents of atomic_bool object self atomically from another atomic_float object n

Parameters

n – atomic_float object

Returns

None

get()

get the contents of atomic_float object atomically.

Returns

the float value

set()

set the contents of atomic_float object atomically.

Parameters

value – the float value to set from

Returns

None

shared_atomic.atomic_boolfloat.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_boolfloat.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_boolfloat.bool_get()

get the contents of atomic_bool object atomically.

Parameters

boolean – atomic_bool object

Returns

the boolean value

shared_atomic.atomic_boolfloat.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_boolfloat.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_boolfloat.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_boolfloat.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_boolfloat.float_get()

get the contents of atomic_float object atomically.

Parameters
  • a – atomic_float object

Returns

the float value

shared_atomic.atomic_boolfloat.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_boolfloat.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