Bool and Float API:

Module shared_atomic

class shared_atomic.atomic_boolfloat. atomic_bool ( value : bool , mode : unicode = 'singleprocessing' , windows_unix_compatibility : bool = False )

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

bool_compare_and_set ( e : self_atomic_bool , n : bool ) bool

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

bool_compare_and_set_value ( e : bool , n : bool ) bool

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

bool_get_and_set ( n : bool ) bool

get and set atomically

Parameters

n – value to set

Returns

original value

bool_shift ( n : self_atomic_bool , r : self_atomic_bool )

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

bool_store ( n : self_atomic_bool )

Store value atomically

Parameters

n – another atomic_bool from which value to set

Returns

None

get ( ) bool

getter

Returns

bool value

set ( value : bool )

setter

Parameters

value – value to set

Returns

None

property value : bool

get and set for the bool number.

class shared_atomic.atomic_boolfloat. atomic_float ( value : double , mode : unicode = 'singleprocessing' )

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

float_store ( n : self_atomic_float )

Store value atomically

Parameters

n – another atomic_float from which value is from

Returns

None

get ( ) double

getter

Returns

value

set ( value : double )

setter

Parameters

value – value to set

Returns

None

property value : double

get and set for the float number.

shared_atomic.atomic_boolfloat. sha1 ( message : bytes ) unicode

calculate sha1(internally used) :return: calculated sha1