Sign in Join
FPDoc Onlineexperiment

TLazThreadedQueue class

In unit LazCollections

Implements a thread-safe FIFO queue for items of a generic type.

Declaration

pascal
TLazThreadedQueue<T> = class

Description

TLazThreadedQueue is generic class which implements a thread-safe FIFO queue using a generic type for its items. The class requires specialization to specify the type stored in the items for the queue. For example:

TLazThreadedQueueString = specialize TLazThreadedQueue<String>;
TLazThreadedQueueInt = specialize TLazThreadedQueue<Integer>;
TLazThreadedQueueRect = specialize TLazThreadedQueue<TRectangle>;

TLazThreadedQueue uses an internal TLazMonitor member to synchronize access to resources in the queue between executing threads. Methods in the class which require thread-safe access use the monitor to enable/disable resource protection. Items in the queue are maintained using the PushItem, PopItem, and PopItemTimeout methods. Properties are provided to determine the size of the queue, and the number of items added or removed.

TLazThreadedQueue specializations are used in the implementation of the fpdserver component, and its integration into the Lazarus IDE.

See also

Properties

FifoQueueprotectedProvides access to the TLazTypedFifoQueue instance used in the class.
QueueSizepublicNumber of storage slots for items in the queue.
TotalItemsPoppedpublicTotal number of items removed from the queue.
TotalItemsPushedpublicTotal number of items added to the queue.
ShutDownpublicIndicates if the DoShutdown method has been called but not finished.

Methods

TryPushItemUnprotectedprotectedTries to push an item onto the queue without resource protection.
TryPopItemUnprotectedprotectedTries to pop an item off of the queue without resource protection.
LockprotectedEnters the Monitor used for resource protection.
UnlockprotectedLeaves the Monitor used for resource protection.
CreateFifoQueueprotectedCreates the TLazTypedFifoQueue instance used in the class.
createpublicConstructor for the class instance.
DestroypublicDestructor for the class instance.
GrowpublicExpands (or shrinks) the allocated storage for the queue by the specified size.
PushItempublicAdds the specified item to the queue.
PopItempublicPops the next item from the queue.
PopItemTimeoutpublicPops an item off the queue with a timeout value.
DoShutDownpublicPerforms actions required when the thread-safe queue is freed.

Types and constants

TLazTypedFifoQueueprotectedType used to the specialize the internal TLazFifoQueue instance for the class.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.