# DownloadPriorityQueue

class in `3d-tiles-renderer/core`

```js
import { DownloadPriorityQueue } from '3d-tiles-renderer/core';
```

Manages a lazily created PriorityQueue per server origin so the requests to every server are
prioritized and limited independently, and a slow or saturated server can never delay the
requests made to others. The items added without a url are managed as their own group.

## Properties

### .running: boolean

readonly

returns whether tasks are queued or actively running in any origin queue

### .maxJobsPerOrigin: number

default `6`

Maximum number of requests that can run concurrently per server.

### .priorityCallback: PriorityCallback | null

default `null`

Comparator used to sort the queued items of every origin queue.

## Methods

### .add

```js
.add( url: string | null, item: any, callback: ItemCallback, signal?: AbortSignal | null ): Promise<any>
```

Adds an item to the queue of the url's server and returns a Promise that resolves when the
item's callback completes, or rejects if the item is removed before running.

- `url`, `string | null`: Url the item requests data from
- `item`, `any`
- `callback`, `ItemCallback`: Invoked with `item` when it is dequeued; may return a Promise
- `signal`, `AbortSignal | null`, optional, default `null`: Removes the item from the queue when aborted

### .remove

```js
.remove( item: any )
```

Removes an item from its origin queue, rejecting its promise with an `AbortError` DOMException.

- `item`, `any`

### .has

```js
.has( item: any ): boolean
```

Returns whether the given item is currently queued.

- `item`, `any`
