Concurrency Control Proposal Overview
Michael Ficarra • TC39 TG5 • 11 October 2024
background & motivation
iterator helpers
async iterator helpers
unordered async�iterator helpers
concurrency control�(this Stage 1 proposal)
proposal goals
AsyncIterator.prototype integration
limit(limit: ??)
an optional concurrency parameter added to all consuming methods
.toArray([ ?? ])
.forEach(fn [, ?? ])
.some(predicate [, ?? ])
.every(predicate [, ?? ])
.find(predicate [, ?? ])
.reduce(reducer [, initialValue [, ?? ]])
proposal goals
AsyncIterator.prototype integration
buffered(limit: integer, prepopulate = false)
limit(limit: integer)
a concurrency parameter (integer) added to all consuming methods
.toArray([ limit ])
.forEach(fn [, limit ])
.some(predicate [, limit ])
.every(predicate [, limit ])
.find(predicate [, limit ])
.reduce(reducer [, initialValue [, limit ]])
proposal goals
CountingGovernor(capacity: integer) class
acquire(): Promise<GovernorToken>
capacity parameter specifies number of concurrent live tokens
GovernorToken.prototype
release(): void === [Symbol.dispose](): void
AsyncIterator.prototype integration
buffered(limit: Governor | integer, prepopulate = false)
limit(limit: Governor | integer)
a concurrency parameter (Governor | integer) added to all consuming methods
.toArray([ governor ])
.forEach(fn [, governor ])
.some(predicate [, governor ])
.every(predicate [, governor ])
.find(predicate [, governor ])
.reduce(reducer [, initialValue [, governor ]])
proposal goals
Governor interface
acquire(): Promise<GovernorToken>
GovernorToken.prototype
release(): void === [Symbol.dispose](): void
CountingGovernor(capacity: integer) class
implementing the Governor interface
capacity parameter specifies number of concurrent live tokens
how do I describe my concurrency limit?
simple concurrency | shared simple concurrency | complex concurrency |
integer | CountingGovernor | a custom Governor |
proposal goals: met