From: Jérôme Benoit Date: Mon, 22 Apr 2024 14:12:32 +0000 (+0200) Subject: fix: refine type definition for transferList X-Git-Tag: v3.1.30~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;ds=sidebyside;h=6a3ecc500583fc68d5bbce89f8448ccd022ab900;p=poolifier.git fix: refine type definition for transferList Signed-off-by: Jérôme Benoit --- diff --git a/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts b/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts index e1a64b15..018cac59 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/@types/fastify/index.d.ts @@ -14,7 +14,7 @@ declare module 'fastify' { execute: ( data?: ThreadWorkerData, name?: string, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ) => Promise } } diff --git a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts index 79d24dc6..f105d7af 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-hybrid/src/fastify-poolifier.ts @@ -38,7 +38,7 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( async ( data?: ThreadWorkerData, name?: string, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ): Promise => await pool.execute(data, name, transferList) ) diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts b/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts index 73f8b071..899aa1a0 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/@types/fastify/index.d.ts @@ -11,7 +11,7 @@ declare module 'fastify' { execute: ( data?: WorkerData, name?: string, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ) => Promise } } diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts index 766ef44e..450a2aea 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts +++ b/examples/typescript/http-server-pool/fastify-worker_threads/src/fastify-poolifier.ts @@ -38,7 +38,7 @@ const fastifyPoolifierPlugin: FastifyPluginCallback = ( async ( data?: WorkerData, name?: string, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ): Promise => await pool.execute(data, name, transferList) ) } diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index b5e528ec..01e621c2 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -893,7 +893,7 @@ export abstract class AbstractPool< public async execute ( data?: Data, name?: string, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ): Promise { return await new Promise((resolve, reject) => { if (!this.started) { @@ -1228,7 +1228,7 @@ export abstract class AbstractPool< protected abstract sendToWorker ( workerNodeKey: number, message: MessageValue, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ): void /** diff --git a/src/pools/pool.ts b/src/pools/pool.ts index d7b6eeab..bcf7d938 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -282,7 +282,7 @@ export interface IPool< readonly execute: ( data?: Data, name?: string, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ) => Promise /** * Starts the minimum number of workers in this pool. diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index 78912c2b..7977cd61 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -51,7 +51,7 @@ export class FixedThreadPool< protected sendToWorker ( workerNodeKey: number, message: MessageValue, - transferList?: TransferListItem[] + transferList?: readonly TransferListItem[] ): void { this.workerNodes[workerNodeKey]?.messageChannel?.port1.postMessage( { diff --git a/src/utility-types.ts b/src/utility-types.ts index c7663606..b3cea1a1 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -82,7 +82,7 @@ export interface Task { /** * Array of transferable objects. */ - readonly transferList?: TransferListItem[] + readonly transferList?: readonly TransferListItem[] /** * Timestamp. */