SyncBool

class thread_factory.concurrency.sync_types.sync_bool.SyncBool(*args, **kwargs)[source]

Bases: ISync

This class provides atomic access and mutation of the internal boolean value, along with logical and bitwise operations such as AND, OR, XOR, and NOT.

SyncBool does not inherit from bool or int to avoid unintentional coercion, but behaves identically for boolean logic and thread-safe use cases.

get() bool[source]

Get the current boolean value in a thread-safe way.

Returns:

The current state of the SyncBool.

Return type:

bool

set(new_value: bool)[source]

Set the boolean value in a thread-safe way.

Parameters:

new_value (bool) – The new boolean state to apply.

toggle()[source]

Atomically invert the current boolean value.

Changes True to False, or False to True, in a thread-safe manner.