# Class TaskQueue<T>

A task queue that limits concurrent execution.

#### Type Parameters

- T

  The return type of tasks in this queue

- Defined in packages/nexus-agents/src/workflows/task-queue.ts:27

##### Index

### Constructors

constructor

### Methods

add
cancel
isCancelled
getRunningCount
getQueuedCount
getAbortSignal

## Constructors

### constructor

- new TaskQueue<T>(concurrency?: number): TaskQueue<T>

  Creates a new TaskQueue.

  #### Type Parameters

  - T

    The return type of tasks in this queue

  #### Parameters

  - concurrency: number = 5

    Maximum number of concurrent tasks (default: 5)

  #### Returns TaskQueue<T>

  - Defined in packages/nexus-agents/src/workflows/task-queue.ts:39

## Methods

### add

- add(task: Task<T>): Promise<T>

  Adds a task to the queue for execution.

  #### Parameters

  - task: Task<T>

    The async task to execute

  #### Returns Promise<T>

  Promise that resolves with the task result

  #### Throws

  Error if the queue has been cancelled

  - Defined in packages/nexus-agents/src/workflows/task-queue.ts:54

### cancel

- cancel(): void

  Cancels all pending and running tasks. Running tasks receive an abort signal.

  #### Returns void

  - Defined in packages/nexus-agents/src/workflows/task-queue.ts:69

### isCancelled

- isCancelled(): boolean

  Returns whether the queue has been cancelled.

  #### Returns boolean

  - Defined in packages/nexus-agents/src/workflows/task-queue.ts:84

### getRunningCount

- getRunningCount(): number

  Returns the number of currently running tasks.

  #### Returns number

  - Defined in packages/nexus-agents/src/workflows/task-queue.ts:91

### getQueuedCount

- getQueuedCount(): number

  Returns the number of tasks waiting in the queue.

  #### Returns number

  - Defined in packages/nexus-agents/src/workflows/task-queue.ts:98

### getAbortSignal

- getAbortSignal(): AbortSignal

  Returns the abort signal for external use.

  #### Returns AbortSignal

  - Defined in packages/nexus-agents/src/workflows/task-queue.ts:105