From 3fd93ff2ac708538e8a22ae329c5df210aaa51fe Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 1 Apr 2024 17:08:16 +0200 Subject: [PATCH] refactor(examples): trivial code cleanups MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- README.md | 8 ++++---- examples/javascript/dynamicExample.cjs | 4 ++-- examples/javascript/fixedExample.cjs | 4 ++-- examples/javascript/multiFunctionExample.cjs | 4 ++-- examples/typescript/pool.ts | 12 ++++++------ 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 6f6e79c7..db52c8c2 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,8 @@ import { DynamicThreadPool, FixedThreadPool, PoolEvents, availableParallelism } // a fixed worker_threads pool const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) }) pool.emitter?.on(PoolEvents.ready, () => console.info('Pool is ready')) @@ -129,8 +129,8 @@ pool.emitter?.on(PoolEvents.busy, () => console.info('Pool is busy')) // or a dynamic worker_threads pool const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) }) pool.emitter?.on(PoolEvents.full, () => console.info('Pool is full')) diff --git a/examples/javascript/dynamicExample.cjs b/examples/javascript/dynamicExample.cjs index e170f59c..a72ce3a6 100644 --- a/examples/javascript/dynamicExample.cjs +++ b/examples/javascript/dynamicExample.cjs @@ -10,8 +10,8 @@ const pool = new DynamicThreadPool( availableParallelism(), './yourWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) } ) let poolFull = 0 diff --git a/examples/javascript/fixedExample.cjs b/examples/javascript/fixedExample.cjs index 38e0c8af..f191aa24 100644 --- a/examples/javascript/fixedExample.cjs +++ b/examples/javascript/fixedExample.cjs @@ -6,8 +6,8 @@ const { } = require('poolifier') const pool = new FixedThreadPool(availableParallelism(), './yourWorker.cjs', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) }) let poolReady = 0 let poolBusy = 0 diff --git a/examples/javascript/multiFunctionExample.cjs b/examples/javascript/multiFunctionExample.cjs index 7ab57ab7..643d117a 100644 --- a/examples/javascript/multiFunctionExample.cjs +++ b/examples/javascript/multiFunctionExample.cjs @@ -5,8 +5,8 @@ const pool = new FixedThreadPool( availableParallelism(), './multiFunctionWorker.cjs', { - errorHandler: e => console.error(e), - onlineHandler: () => console.info('worker is online') + onlineHandler: () => console.info('worker is online'), + errorHandler: e => console.error(e) } ) diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index fb48f7b0..3965e1f0 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -18,11 +18,11 @@ const fixedPool = new FixedThreadPool( availableParallelism(), workerFile, { - errorHandler: (e: Error) => { - console.error(e) - }, onlineHandler: () => { console.info('Worker is online') + }, + errorHandler: (e: Error) => { + console.error(e) } } ) @@ -34,11 +34,11 @@ const dynamicPool = new DynamicThreadPool( availableParallelism(), workerFile, { - errorHandler: (e: Error) => { - console.error(e) - }, onlineHandler: () => { console.info('Worker is online') + }, + errorHandler: (e: Error) => { + console.error(e) } } ) -- 2.34.1