Skip to content

Commit 3e98f70

Browse files
committed
Fix bugs
1 parent b6fd8fa commit 3e98f70

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

JavaScript/8-await-counting.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
const fs = require('fs');
4-
53
class CountingSemaphore {
64
constructor(concurrency) {
75
this.counter = concurrency;
@@ -31,6 +29,8 @@ class CountingSemaphore {
3129

3230
// Usage
3331

32+
const semaphore = new CountingSemaphore(3);
33+
3434
const job = async (task) => {
3535
console.log('try enter', task);
3636
await semaphore.enter();
@@ -41,5 +41,4 @@ const job = async (task) => {
4141
}, 1000);
4242
};
4343

44-
const semaphore = new CountingSemaphore(3);
4544
for (let i = 0; i < 100; i++) job(i);

0 commit comments

Comments
 (0)