This class implements a queue which is used to transfer data from one task to another. More...
Public Member Functions | |
def | __init__ (self, type_code, size, thread_protect=True, overwrite=False, name=None) |
Initialize a queue by allocating memory for the contents and setting up the components in an empty configuration. More... | |
def | put (self, item, in_ISR=False) |
Put an item into the queue. More... | |
def | get (self, in_ISR=False) |
Read an item from the queue. More... | |
def | any (self) |
Returns True if there are any items in the queue and False if the queue is empty. More... | |
def | empty (self) |
Returns True if there are no items in the queue and False if there are any items therein. More... | |
def | full (self) |
This method returns True if the queue is already full and there is no room for more data without overwriting existing data. More... | |
def | num_in (self) |
This method returns the number of items which are currently in the queue. More... | |
def | __repr__ (self) |
This method puts diagnostic information about the queue into a string. | |
Static Public Attributes | |
int | ser_num = 0 |
A counter used to give serial numbers to queues for diagnostic use. | |
This class implements a queue which is used to transfer data from one task to another.
If parameter 'thread_protect' is True
, the transfer will be protected from corruption in the case that one thread might interrupt another due to threading or due to one thread being run as an interrupt service routine.
def task_share.Queue.__init__ | ( | self, | |
type_code, | |||
size, | |||
thread_protect = True , |
|||
overwrite = False , |
|||
name = None |
|||
) |
Initialize a queue by allocating memory for the contents and setting up the components in an empty configuration.
The data type code is given as for the Python 'array' type, which can be any of
type_code | The type of data items which the queue can hold |
size | The maximum number of items which the queue can hold |
thread_protect | True if mutual exclusion protection is used |
overwrite | If True , oldest data will be overwritten with new data if the queue becomes full |
name | A short name for the queue, default QueueN where N is a serial number for the queue |
def task_share.Queue.any | ( | self | ) |
Returns True
if there are any items in the queue and False
if the queue is empty.
True
if items are in the queue, False
if not def task_share.Queue.empty | ( | self | ) |
Returns True
if there are no items in the queue and False
if there are any items therein.
True
if queue is empty, False
if it's not empty def task_share.Queue.full | ( | self | ) |
This method returns True
if the queue is already full and there is no room for more data without overwriting existing data.
True
if the queue is full def task_share.Queue.get | ( | self, | |
in_ISR = False |
|||
) |
Read an item from the queue.
If there isn't anything in there, wait (blocking the calling process) until something becomes available. If non-blocking reads are needed, one should call any()
to check for items before attempting to read any items.
in_ISR | Set this to True if calling from within an ISR |
def task_share.Queue.num_in | ( | self | ) |
This method returns the number of items which are currently in the queue.
def task_share.Queue.put | ( | self, | |
item, | |||
in_ISR = False |
|||
) |
Put an item into the queue.
If there isn't room for the item, wait (blocking the calling process) until room becomes available, unless the overwrite
constructor parameter was set to True
to allow old data to be clobbered. If non-blocking behavior without overwriting is needed, one should call full()
to ensure that the queue is not full before putting data into it.
item | The item to be placed into the queue |
in_ISR | Set this to True if calling from within an ISR |