Shares Class¶
Implements a very simple interface for sharing data between multiple tasks. Shares are simple variables, while queues are lists. Both data types are accessable from anywhere.
- class shares.Queue¶
Bases:
object
A queue of shared data. Values can be accessed with placed into queue with put() or removed from the queue with get(). Check if there are items in the queue with num_in() before using get().
- get()¶
Remove the first item from the front of the queue
- Returns
The value of the item removed
- num_in()¶
Find the number of items in the queue. Call before get().
- Returns
The number of items in the queue
- put(item)¶
Adds an item to the end of the queue.
- Parameters
item – The new item to append to the queue.
- class shares.Share(initial_value=None)¶
Bases:
object
A standard shared variable. Values can be accessed with read() or changed with write()
- read()¶
Access the value of the shared variable
- Returns
The value of the shared variable
- write(item)¶
Updates the value of the shared variable.
- Parameters
item – The new value for the shared variable.