Prajna


Component<'T>

A component class provides a generic tool to build a processing pipeline using a threadpool It provides the following functionality: 1. An arbitrary object (an item of type 'T) is dequeue from a queue - a queue must have a BaseQ as a base class 2. The object is repeatedly "processed" until the processing says it is finished by arbirary piece of processing code The processing code returns a tuple of (bool, ManualResetEvent): (complete, event) When complete == true, then item has completed and new item is to be dequeued When event <> null, then processing cannot continue and must wait for event to fire before trying again There may be cases when complete is true, but event is not null, in these cases, processing waits for event to fire However, if complete is false, event must be non-null The processing may occur on its own thread or on a threadpool If event <> null, - If threadpool is being used, the component processing is removed from the threadpool work item queue and gets requeued once event fires - If processing is occuring on own thread, then that thread blocks for event to fire There is also support for multiple processing steps to take place in a single item

Constructors

ConstructorDescription
new()
Signature: unit -> Component<'T>

Instance members

Instance memberDescription
AddProc(processItem)
Signature: (processItem:('T -> ManualResetEvent)) -> string

Register a processor for the component - same as RegisterProc, but default name is created and returned A function which does processing, returns event if cannot complete The internal name of the processor - can use for unregistering

Close()
Signature: unit -> unit -> unit

A function to execute when no more items are in queue and IsClosed returns true

Close()
Signature: unit -> unit

A function to execute when no more items are in queue and IsClosed returns true

Dequeue()
Signature: unit -> 'T ref -> bool * ManualResetEvent

A function which dequeues data from the internal BaseQ

Dequeue()
Signature: unit -> unit

A function which dequeues data from the internal BaseQ

GetOrAddProc(name, processItem)
Signature: (name:string * processItem:('T -> ManualResetEvent)) -> unit

Get or add a new processor for the component with name If this is used, the Proc property does not need to be set The name of the processing component - used for unregistering A function which does processing, returns event if cannot complete

InitMultipleProcess()
Signature: unit -> unit

Initialize the use of multiple processors - this is useful if multiple actions need to be performed on each item in the queue - use AddProc/RegisterProc to add processing, UnregisterProc to remove processing

IsClosed()
Signature: unit -> unit -> bool

A (unit->bool) function which returns true/false to tell if any more data needs to be processed

IsClosed()
Signature: unit -> unit

A (unit->bool) function which returns true/false to tell if any more data needs to be processed

Proc()
Signature: unit -> 'T -> bool * ManualResetEvent

A function which processes each item, if multiple processing needs to take place, use AddProc or RegisterItem to add processing and UnregisterItem to remove processing

Proc()
Signature: unit -> unit

A function which processes each item, if multiple processing needs to take place, use AddProc or RegisterItem to add processing and UnregisterItem to remove processing

Q()
Signature: unit -> BaseQ<'T>

The internal component Q into which elements are queued for processing

Q()
Signature: unit -> unit

The internal component Q into which elements are queued for processing

RegisterProc(name, processItem)
Signature: (name:string * processItem:('T -> ManualResetEvent)) -> unit

Register a processor for the component with name If this is used, the Proc property does not need to be set The name of the processing component - used for unregistering A function which does processing, returns event if cannot complete

ReleaseAllItems()
Signature: unit -> unit
ReleaseItem()
Signature: unit -> 'T ref -> unit

A function which gets executed once an item is finished processing

ReleaseItem()
Signature: unit -> unit

A function which gets executed once an item is finished processing

SelfClose()
Signature: unit -> unit
Modifiers: abstract

Self close the component and start closing the pipeline

SelfTerminate()
Signature: unit -> unit
Modifiers: abstract

Self terminate the component and start terminating the pipeline

Terminate()
Signature: unit -> unit -> unit

A function to execute for non-graceful termination, i.e. without waiting for queue to empty

Terminate()
Signature: unit -> unit

A function to execute for non-graceful termination, i.e. without waiting for queue to empty

UnregisterProc(name)
Signature: name:string -> unit

Unregister a processor for the component The name of the processing to be removed

Static members

Static memberDescription
DefaultClose(...)
Signature: self:Component<'T> -> nextComponent:Component<'TN> -> (triggerNext:Option<(unit -> unit)>) -> unit -> unit

A default "Close" function which can be used A reference to the component An option for code to execute after close done

DefaultTerminate(...)
Signature: self:Component<'T> -> nextComponent:Component<'TN> -> (triggerNext:Option<(unit -> unit)>) -> unit -> unit

A default "Terminate" function which can be used A reference to the component A reference to next component in pipeline - can be set to null An option for code to execute after terminate done

StartProcessOnOwnThread(...)
Signature: (proc:(unit -> ManualResetEvent * bool)) -> tpKey:'TP -> (fnCb:Option<(unit -> unit)>) -> (infoFunc:('TP -> string)) -> unit

Start component processing on own thread A key to identify the thread A function which returns information about the thread

Fork me on GitHub