repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
chore: generate documentation
[poolifier.git]
/
examples
/
typescript
/
pool.ts
diff --git
a/examples/typescript/pool.ts
b/examples/typescript/pool.ts
index 869e62a8bf718020c155ae221b85921735a61d74..54b437ab31b2f1d7785439c5ce9007167e554331 100644
(file)
--- a/
examples/typescript/pool.ts
+++ b/
examples/typescript/pool.ts
@@
-1,9
+1,13
@@
import { join } from 'path'
import type { MyData, MyResponse } from './worker'
import { join } from 'path'
import type { MyData, MyResponse } from './worker'
-import { DynamicThreadPool, FixedThreadPool } from 'poolifier'
+import {
+ DynamicThreadPool,
+ FixedThreadPool,
+ availableParallelism
+} from 'poolifier'
export const fixedPool = new FixedThreadPool<MyData, Promise<MyResponse>>(
export const fixedPool = new FixedThreadPool<MyData, Promise<MyResponse>>(
-
8
,
+
availableParallelism()
,
join(__dirname, 'worker.js'),
{
errorHandler: (e: Error) => {
join(__dirname, 'worker.js'),
{
errorHandler: (e: Error) => {
@@
-16,8
+20,8
@@
export const fixedPool = new FixedThreadPool<MyData, Promise<MyResponse>>(
)
export const dynamicPool = new DynamicThreadPool<MyData, Promise<MyResponse>>(
)
export const dynamicPool = new DynamicThreadPool<MyData, Promise<MyResponse>>(
-
2
,
-
8
,
+
Math.floor(availableParallelism() / 2)
,
+
availableParallelism()
,
join(__dirname, 'worker.js'),
{
errorHandler: (e: Error) => {
join(__dirname, 'worker.js'),
{
errorHandler: (e: Error) => {