Skip to content

Commit

Permalink
feat: empty and full stat
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannchie committed Mar 19, 2021
1 parent 0500da0 commit c835263
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ export class Semaphore {
private count: number;
private concurrency: number;
private waitingTasks: PromiseInfo[];

get empty() {
return this.count === 0;
}

get full() {
return this.concurrency === this.count;
}
constructor(concurrency: number) {
if (concurrency <= 0) {
throw new Error("Concurrency Should greater then 0!");
Expand Down

0 comments on commit c835263

Please sign in to comment.