TileRequestChannel Class

A channel over which requests for tile content can be made. The channel may request content over HTTP, calls to the backend via IPC or RPC, or any other method like generating the content on the frontend. The channel consists of a queue of pending requests and a set of "active" requests (dispatched and awaiting a response). Incoming requests are placed onto the queue. Requests are popped of the queue in order of priority and dispatched, until the maximum number of simultaneously-active requests is reached. The maximum number of active requests depends on the transport mechanism. For HTTP 1.1, browsers impose a limit of 6 simultaneous connections to a given domain, so ideally each unique domain will use its own unique channel with a limit of 6 active requests. Even for requests satisfied entirely by the frontend, imposing a limit is important for throttling the amount of work done at one time, especially because as the user navigates the view, tiles that were previously requested may no longer be of interest and we shouldn't waste resources producing their content. A channel must be registered with TileRequestChannels and must have a unique name among all registered channels.

see TileRequestChannels.getForHttp to obtain (and register if not already registered) an HTTP-based channel.

see TileAdmin.channels for the channels configured for use with the iTwin.js display system.

see Tile.channel to specify the channel to be used to request a given tile's content.


Name Description
constructor(name: string, concurrency: number): TileRequestChannel Create a new channel.  
cancel(request: TileRequest): void Protected Protected only for tests - do not override.  
cancelAndClearAll(): void Cancel all active and queued requests and clear the active set and queue.  
dispatch(request: TileRequest): void Protected Protected only for tests - do not override.  
dropActiveRequest(request: TileRequest): void Protected Protected only for tests - do not override.  
onActiveRequestCanceled(_request: TileRequest): void Invoked when a request that was previously dispatched is canceled before a response is received.  
onIModelClosed(_iModel: IModelConnection): void Invoked when an iModel is closed, to clean up any state associated with that iModel.  
onNoContent(_request: TileRequest): boolean Invoked when Tile.requestContent returns undefined.  
process(): void Invoked by TileRequestChannels.process to process the active and pending requests.  
processCancellations(): void Invoked to do any additional work to cancel tiles accumulated by TileRequestChannel.onActiveRequestCanceled.  
recordCompletion(tile: Tile): void Invoked by TileRequest after a request completes.  
recordFailure(): void Invoked by TileRequest when a request fails to produce a response.  
recordTimeout(): void Invoked by TileRequest when a request times out.  
requestContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response> Request content for the specified tile.  
resetStatistics(): void Reset all of this channel's TileRequestChannel.statistics to zero.  
swapPending(): void Invoked by TileRequestChannels.swapPending when TileAdmin is about to start enqueuing new requests.  


Name Type Description
_active Protected Set<TileRequest> Protected strictly for tests.  
_statistics Protected TileRequestChannelStatistics    
concurrency Accessor number The maximum number of active requests.  
name string The channel's name.  
numActive Accessor ReadOnly number The number of requests that have been dispatched and are awaiting a response.  
numPending Accessor ReadOnly number The number of requests that have been enqueued for later dispatch.  
size Accessor ReadOnly number The total number of requests in this channel, whether dispatched or enqueued.  
statistics Accessor ReadOnly Readonly<TileRequestChannelStatistics> Statistics intended primarily for debugging.  

Defined in

Last Updated: 02 April, 2021