Blocking collections
Before I start discussing parallel patterns in OmniThreadLibrary, I’ll spend a few pages explaining a data structure that is used by many of these patterns – a blocking collection. It is a thread-safe queue of unlimited size that supports multiple simultaneous readers and writers. The IOmniBlockingCollection
interface, implemented in the OtlCollections
unit, is based on the .NET BlockingCollection
class and is shown in full here:
IOmniBlockingCollection = interface procedure Add(const value: TOmniValue); procedure CompleteAdding; function GetEnumerator: IOmniValueEnumerator; function IsCompleted: boolean; function IsEmpty: boolean; function IsFinalized: boolean; function Next: TOmniValue; procedure ReraiseExceptions(enable: boolean = true); procedure SetThrottling(highWatermark, lowWatermark...