2.13.10Class SyncQueue

Signaler of relevant processing conditions.

Class SyncQueue from \
                 Waitable( )

This class implements a synchronized Falcon items FIFO or LIFO queue that can be waited on for non-empty status.

A single waiting thread will acquire the queue when it is not empty; at that point, it can dequeue one or more items being previously pushed, released the queue and processed the dequeued items.

Holding the queue in acquired status prevents concurrent insertion of new items, as well as removal, so it's advisable to release the queue as soon as possible, that is, as soon as the items that must be processed are retrieved.

Note: Always remember that items in the queue are serialized copies coming from the pushing VMs. Serialization is a relatively expensive operation for non-simple types, and may cause error raising if the pushed items are not serializable.

Methods
emptyReturns true if the queue is empty.
popPops an item from the back of the queue.
popFrontPops an item from the front of the queue.
pushPushes an item at the end of the queue.
pushFrontPushes an item in front of the queue.
sizeReturns the count of elements currently stored in the queue.
Methods inherited from class Waitable
releaseReleases a structure acquired by a waiting function.

Methods

empty

Returns true if the queue is empty.

SyncQueue.empty()
ReturnTrue if the queue is empty.

Although it is possible to call this method in any moment, it is consistent to call it only when the queue has been acquired through a succesful wait.

pop

Pops an item from the back of the queue.

SyncQueue.pop()
ReturnThe item that was at the end of the queue.
Raise
ThreadError if the queue is empty.

This method removes an item from the end of the queue and returns it to the caller.

popFront

Pops an item from the front of the queue.

SyncQueue.popFront()
ReturnThe item that was in front of the queue.
Raise
ThreadError if the queue is empty.

This method removes an item in front of the queue and returns it to the caller.

push

Pushes an item at the end of the queue.

SyncQueue.push( item )
item The item to be pushed
Raise
CodeError if the item is not serializable.

This method adds an item at the end of the queue. If the queue was empty, waiting threads may be signaled to receive the added item.

The item parameter must be a serializable item, or a CodeError will be raised.

pushFront

Pushes an item in front of the queue.

SyncQueue.pushFront( item )
item The item to be pushed
Raise
CodeError if the item is not serializable.

This method adds an item in front of the queue. If the queue was empty, waiting threads may be signaled to receive the added item.

The item parameter must be a serializable item, or a CodeError will be raised.

size

Returns the count of elements currently stored in the queue.

SyncQueue.size()
ReturnNumber of elements currently held in the queue.

Although it is possible to call this method in any moment, it is consistent to call it only when the queue has been acquired through a succesful wait.

Made with http://www.falconpl.org