@travetto/worker 3.0.3 → 3.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -159,8 +159,9 @@ export async function main(): Promise<void> {
159
159
 
160
160
  exec.send('ready'); // Indicate the child is ready to receive requests
161
161
 
162
- const heartbeat = (): void => { timers.setTimeout(5000).then(heartbeat); }; // Keep-alive
163
- heartbeat();
162
+ for await (const _ of timers.setInterval(5000)) {
163
+ // Keep-alive
164
+ }
164
165
  }
165
166
  ```
166
167
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/worker",
3
- "version": "3.0.3",
3
+ "version": "3.1.0-rc.1",
4
4
  "description": "Process management utilities, with a focus on inter-process communication",
5
5
  "keywords": [
6
6
  "exec",
@@ -25,7 +25,7 @@
25
25
  "directory": "module/worker"
26
26
  },
27
27
  "dependencies": {
28
- "@travetto/base": "^3.0.3",
28
+ "@travetto/base": "^3.1.0-rc.1",
29
29
  "generic-pool": "^3.9.0"
30
30
  },
31
31
  "travetto": {
@@ -27,7 +27,7 @@ export class ManualAsyncIterator<X> implements AsyncIterator<X>, AsyncIterable<X
27
27
  * Wait for next event to fire
28
28
  */
29
29
  async next(): Promise<IteratorResult<X>> {
30
- if (!this.#done && !this.#queue.length) {
30
+ while (!this.#done && !this.#queue.length) {
31
31
  await this.#ready;
32
32
  this.#ready = Util.resolvablePromise();
33
33
  }
package/src/pool.ts CHANGED
@@ -30,7 +30,8 @@ type WorkCompletionEvent<X> = { idx: number, total?: number, value: X };
30
30
  */
31
31
  export class WorkPool<X> {
32
32
 
33
- static DEFAULT_SIZE = Math.min(os.cpus().length - 1, 4);
33
+ static MAX_SIZE = os.cpus().length - 1;
34
+ static DEFAULT_SIZE = Math.min(WorkPool.MAX_SIZE, 4);
34
35
 
35
36
  /**
36
37
  * Generic-pool pool