mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Domain specific data files
This commit is contained in:
parent
81577ad621
commit
f87e165084
9 changed files with 174 additions and 71 deletions
|
@ -27,7 +27,7 @@ export function doALongTask(obj: any): Promise<any> {
|
|||
resolve(res)
|
||||
// TODO: check if result is really a result, and want to release port
|
||||
pool.release(client)
|
||||
console.log('[RELEASE]: #' + client.index)
|
||||
// console.log('[RELEASE]: #' + client.index)
|
||||
})
|
||||
})
|
||||
.catch(function(err) {
|
||||
|
@ -56,9 +56,9 @@ export function initWorkerPool(initData: any): void {
|
|||
}
|
||||
},
|
||||
destroy: function(client) {
|
||||
console.log('[DESTROY]')
|
||||
// console.log('[DESTROY]')
|
||||
client.worker.terminate()
|
||||
console.log('[DESTROYED] #' + client.index)
|
||||
// console.log('[DESTROYED] #' + client.index)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -115,9 +115,9 @@ function getAWorker(i, initData) {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
function doSomething(client, obj) {
|
||||
const { index, worker } = client
|
||||
const { /* index, */ worker } = client
|
||||
return new Promise((resolve) => {
|
||||
console.log('[ACCUIRE]: #' + index)
|
||||
// console.log('[ACCUIRE]: #' + index)
|
||||
worker.postMessage(obj)
|
||||
worker.once('message', (msg) => {
|
||||
resolve(msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue