File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 11import { Governor } from "./governor.js" ;
22
33export class Semaphore extends Governor {
4- #limit : number ;
4+ #capacity : number ;
55 #acquired: number = 0 ;
66 #wait: PromiseWithResolvers < void > | null = null ;
77 #idleListeners: ( ( ) => void ) [ ] = [ ] ;
88
9- constructor ( limit : number ) {
10- if ( ( limit >>> 0 ) !== limit ) {
11- throw new TypeError ( "Limit must be an integer" ) ;
9+ constructor ( capacity : number ) {
10+ if ( ( capacity >>> 0 ) !== capacity ) {
11+ throw new TypeError ( "capacity must be an integer" ) ;
1212 }
13- if ( limit < 0 ) {
14- throw new RangeError ( "Limit must be non-negative" ) ;
13+ if ( capacity < 0 ) {
14+ throw new RangeError ( "capacity must be non-negative" ) ;
1515 }
1616 super ( ) ;
1717
18- this . #limit = limit ;
18+ this . #capacity = capacity ;
1919 }
2020
2121 async acquire ( ) {
22- while ( this . #acquired >= this . #limit ) {
22+ while ( this . #acquired >= this . #capacity ) {
2323 if ( ! this . #wait) {
2424 this . #wait = Promise . withResolvers < void > ( ) ;
2525 }
You can’t perform that action at this time.
0 commit comments