Class TaskPool
- Namespace
- FoundationaLLM.Common.Tasks
- Assembly
- FoundationaLLM.Common.dll
Represents a pool of active tasks with a predefined capacity.
public class TaskPool
- Inheritance
-
TaskPool
- Inherited Members
- Extension Methods
Remarks
This class is not thread safe, it assumes the taks pool is managed from a single thread.
Constructors
TaskPool(int, ILogger)
Constructs a task pool with a specified capacity.
public TaskPool(int maxConcurrentTasks, ILogger logger)
Parameters
maxConcurrentTasks
intIndicates the maximum number of tasks accepted by the task pool.
logger
ILoggerThe ILogger used for logging.
Properties
AvailableCapacity
Indicates whether the task pool is at capacity or not.
public int AvailableCapacity { get; }
Property Value
Methods
Add(IEnumerable<TaskInfo>)
Adds a new batch of tasks to the task pool.
public void Add(IEnumerable<TaskInfo> tasks)
Parameters
tasks
IEnumerable<TaskInfo>The list of TaskInfo items to be added to the pool.
Exceptions
- TaskPoolException
The exception raised when a task cannot be added to the pool (e.g., the task pool is at capacity).
HasRunningTaskForPayload(string)
Determines whether the task pool already has a running task for a specified payload id.
public bool HasRunningTaskForPayload(string payloadId)
Parameters
payloadId
stringThe identifier of the payload.
Returns
- bool
True if the task pool already has a running task for the specified payload, false otherwise.