You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes people want the ability to acquire with higher or lower priority.
You can build that on top of the existing interface easily enough:
classPriorityGovernor{
#queue =newMinHeap;// pretend we have a MinHeap
#underlying;constructor(underlying){this.#underlying =underlying;}with(fn,priority){letcap=Promise.withResolvers();this.#queue.add({ cap, fn, priority });this.#advance();returncap.promise;}// other methods omitted
#advance(){this.#underlying.with(async()=>{let{ fn, cap }=this.#queue.shift();try{cap.resolve(fn());}catch(e){cap.reject(e);}});}}
but maybe it's worth including?
The text was updated successfully, but these errors were encountered:
Sometimes people want the ability to acquire with higher or lower priority.
You can build that on top of the existing interface easily enough:
but maybe it's worth including?
The text was updated successfully, but these errors were encountered: