Table of Contents

Class ConcurrentTaskPool

Namespace
FoundationaLLM.Common.Tasks
Assembly
FoundationaLLM.Common.dll

Represents a pool of active tasks with a predefined capacity.

public class ConcurrentTaskPool
Inheritance
ConcurrentTaskPool
Inherited Members
Extension Methods

Remarks

This class is thread safe.

Constructors

ConcurrentTaskPool(int, ILogger<ConcurrentTaskPool>)

Constructs a task pool with a specified capacity.

public ConcurrentTaskPool(int maxConcurrentTasks, ILogger<ConcurrentTaskPool> logger)

Parameters

maxConcurrentTasks int

Indicates the maximum number of tasks accepted by the task pool.

logger ILogger<ConcurrentTaskPool>

The ILogger used for logging.

Properties

AvailableCapacity

Indicates whether the task pool is at capacity or not.

public int AvailableCapacity { get; }

Property Value

int

Methods

HasRunningTaskForPayload(string)

Determines whether the task pool already has a running task for a specified payload id.

public bool HasRunningTaskForPayload(string payloadId)

Parameters

payloadId string

The identifier of the payload.

Returns

bool

True if the task pool already has a running task for the specified payload, false otherwise.

TryAdd(IEnumerable<TaskInfo>)

Adds a new batch of tasks to the task pool.

public bool TryAdd(IEnumerable<TaskInfo> tasks)

Parameters

tasks IEnumerable<TaskInfo>

The list of TaskInfo items to be added to the pool.

Returns

bool

Exceptions

TaskPoolException

The exception raised when a task cannot be added to the pool (e.g., the task pool is at capacity).