repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: cleanup default arguments handling
[poolifier.git]
/
examples
/
typescript
/
worker.ts
diff --git
a/examples/typescript/worker.ts
b/examples/typescript/worker.ts
index ff75fb44f3b15707a7b27f76b00fa2937a8044ac..562b21477e31dd1aaa603a087eb33d3c92b4b130 100644
(file)
--- a/
examples/typescript/worker.ts
+++ b/
examples/typescript/worker.ts
@@
-1,7
+1,7
@@
import { ThreadWorker } from 'poolifier'
export interface MyData {
import { ThreadWorker } from 'poolifier'
export interface MyData {
- ok:
number
+ ok:
0 | 1
}
export interface MyResponse {
}
export interface MyResponse {
@@
-11,17
+11,16
@@
export interface MyResponse {
class MyThreadWorker extends ThreadWorker<MyData, Promise<MyResponse>> {
constructor () {
class MyThreadWorker extends ThreadWorker<MyData, Promise<MyResponse>> {
constructor () {
- super(data => this.process(data), {
- maxInactiveTime: 60000,
- async: true
+ super(async (data: MyData) => await this.process(data), {
+ maxInactiveTime: 60000
})
}
private async process (data: MyData): Promise<MyResponse> {
})
}
private async process (data: MyData): Promise<MyResponse> {
- return new Promise(resolve => {
+ return
await
new Promise(resolve => {
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
setTimeout(() => {
resolve({ message: 'Hello from Worker :)', data })
- }, 10
_
000)
+ }, 10000)
})
}
}
})
}
}