TROThreadPool

Overview

The TROThreadPool class is used by the Remoting SDK to perform a number of tasks with the help of certain threads. As soon as a thread completes its task, it will request the next task from the TROSemaphore queue.
All implementations of super channels use the TROThreadPool class to provide asynchronous calls and server callbacks (see the use case).

Location


 

constructor Create  override

Creates a new instance.

constructor Create(aOwner: TComponent)

Parameters:

  • aOwner: Owner.

Assign  override

Copies data from a given source.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

GetCurrQueueSize

Returns the current count of tasks in the queue.

function GetCurrQueueSize: Integer

MaxQueue

Restricts the queue size (50 by default), which is checked by the QueueItem method.

property MaxQueue: Integer read write

MaxThreads

Restricts the maximum thread count (10 by default), which is checked by the QueueItem method.

property MaxThreads: Integer read write

PoolThreads

This property is used for heuristic balancing between the number of threads and the queue length (5 by default).

property PoolThreads: Integer read write

QueueItem

Puts a task (Callback) into the queue. The method checks the MaxQueue and MaxThreads parameters to see if they would be exceeded, in which case it spawns a new thread (based on the values of the MaxQueue, MaxThreads and PoolThreads heuristic). The EROException will be raised if the MaxQueue or MaxThreads limit is reached.

procedure QueueItem(Callback: IROThreadPoolCallback)

Parameters:

  • Callback: Task to perform

 

MaxQueue

Restricts the queue size (50 by default), which is checked by the QueueItem method.

property MaxQueue: Integer read write

MaxThreads

Restricts the maximum thread count (10 by default), which is checked by the QueueItem method.

property MaxThreads: Integer read write

PoolThreads

This property is used for heuristic balancing between the number of threads and the queue length (5 by default).

property PoolThreads: Integer read write

 

constructor Create  override

Creates a new instance.

constructor Create(aOwner: TComponent)

Parameters:

  • aOwner: Owner.

Assign  override

Copies data from a given source.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

GetCurrQueueSize

Returns the current count of tasks in the queue.

function GetCurrQueueSize: Integer

QueueItem

Puts a task (Callback) into the queue. The method checks the MaxQueue and MaxThreads parameters to see if they would be exceeded, in which case it spawns a new thread (based on the values of the MaxQueue, MaxThreads and PoolThreads heuristic). The EROException will be raised if the MaxQueue or MaxThreads limit is reached.

procedure QueueItem(Callback: IROThreadPoolCallback)

Parameters:

  • Callback: Task to perform