Skip to content

Commit 78ba7ea

Browse files
limit → capacity
1 parent 145b31b commit 78ba7ea

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/semaphore.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { Governor } from "./governor.js";
22

33
export 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
}

0 commit comments

Comments
 (0)