OneAtATimeAction<T> Class

Orchestrator of a one-at-a-time activity. This concept is useful only for replaceable operations (that is, operations where subsequent requests replace and obviate the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP request queue to grow such that the delay to service new requests is unbounded.

With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes pending. If subsequent requests arrive with a pending request, the current pending request is abandoned (its Promise is rejected) and the new request becomes pending. When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type of operation, but the first and last request will always eventually complete.

Methods

Name Description
constructor<T>(run: (...args: any[]) => Promise<T>, msg: string = "abandoned"): OneAtATimeAction<T> Ctor for OneAtATimePromise.  
request(...args: any[]): Promise<T> Add a new request to this OneAtATimePromise.  

Properties

Name Type Description
msg string    

Defined in

Last Updated: 15 March, 2024