Skip to content

Commit

Permalink
feat: add threads start manager
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Nov 18, 2024
1 parent 77dde0e commit df8bd04
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/threads/start-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ export default class StartManager {
await this.#startMutex.wait();
}

// XXX
// wait for active requests finished
if ( graceful ) {
await this.#activeRequestsCounter.wait();
}

// stop
var res;

Expand All @@ -118,20 +124,15 @@ export default class StartManager {
// stopped
if ( res.ok ) {
this.#isStarted = false;
}

// wait for active requests finished
if ( graceful ) {
await this.#activeRequestsCounter.wait();
}

const abortController = this.#abortController;
var abortController = this.#abortController;

this.#abortController = new AbortController();
this.#abortController = new AbortController();
}

this.#stopMutex.unlock( res );

abortController.abort();
abortController?.abort();

return res;
}
Expand Down

0 comments on commit df8bd04

Please sign in to comment.