FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
poolifier/examples/javascript/fixedExample.mjs at master · poolifier/poolifier · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
poolifier
/
poolifier
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
17
Star
454
Code
Issues
13
Pull requests
5
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
poolifier
/
examples
/
javascript
/
fixedExample.mjs
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (29 loc) · 946 Bytes
Breadcrumbs
poolifier
/
examples
/
javascript
/
fixedExample.mjs
Copy path
File metadata and controls
31 lines (29 loc) · 946 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import
{
availableParallelism
,
FixedThreadPool
,
PoolEvents
}
from
'poolifier'
const
pool
=
new
FixedThreadPool
(
availableParallelism
(
)
,
'./yourWorker.mjs'
,
{
errorHandler
:
e
=>
console
.
error
(
e
)
,
onlineHandler
:
(
)
=>
console
.
info
(
'worker is online'
)
,
}
)
let
poolReady
=
0
let
poolBusy
=
0
pool
.
emitter
?.
on
(
PoolEvents
.
ready
,
(
)
=>
poolReady
++
)
pool
.
emitter
?.
on
(
PoolEvents
.
busy
,
(
)
=>
poolBusy
++
)
let
resolved
=
0
const
start
=
performance
.
now
(
)
const
iterations
=
1000
for
(
let
i
=
1
;
i
<=
iterations
;
i
++
)
{
pool
.
execute
(
)
.
then
(
(
)
=>
{
resolved
++
if
(
resolved
===
iterations
)
{
console
.
info
(
`Time taken is
${
(
performance
.
now
(
)
-
start
)
.
toFixed
(
2
)
}
ms`
)
console
.
info
(
`The pool was ready for
${
poolReady
}
times`
)
console
.
info
(
`The pool was busy for
${
poolBusy
}
times`
)
return
pool
.
destroy
(
)
}
return
undefined
}
)
.
catch
(
err
=>
console
.
error
(
err
)
)
}
Back
|
FazBrowse Home
|
New Git URL