mcollina / fastq

Fast, in memory work queue
ISC License
932 stars 47 forks source link

multithreading or parallel processing #52

Closed omymy1 closed 3 years ago

omymy1 commented 3 years ago

Is Job or task multi-threading or parallel processing available in this package(with async no sync)? Please tell me what is the difference between fastseries & fastparallel?

mcollina commented 3 years ago

Is Job or task multi-threading or parallel processing available in this package(with async no sync)?

There is no multithreading in this library. It parallelize execution up to the worker limit.

mcollina commented 3 years ago

Please tell me what is the difference between fastseries & fastparallel?

It's a mixture of both. It parallelize things up to a limit.

omymy1 commented 3 years ago

Thank Youu For Your Answer

omymy1 commented 3 years ago

I have last question How to queue Async Job without await?

mcollina commented 3 years ago

just add a .catch(console.log) handler to them.

omymy1 commented 3 years ago

function wait(milliseconds) { return new Promise(resolve => { setTimeout(() => { resolve(true) }, milliseconds) }); } import * as fastq from "fastq"; import type { queueAsPromised } from "fastq"; const q: queueAsPromised = fastq.promise(asyncWorker, 1) q.push(wait(1000)).catch((err) => console.error(err)) async function asyncWorker(arg): Promise { console.log(arg) }

output- promise { pending }

mcollina commented 3 years ago

that code works exactly as expected. I probably did not understand your question.

omymy1 commented 3 years ago

My question is- What is the difference between fastq and async, How fastq help increase performance and concatency? Please answer my questions, that will very help full for me.

function wait(milliseconds) { return new Promise(resolve => { setTimeout(() => { resolve(true) }, milliseconds) }); } import * as fastq from "fastq"; import type { queueAsPromised } from "fastq"; const q: queueAsPromised = fastq.promise(asyncWorker, 1) q.push(wait(1000)).catch((err) => console.error(err)) async function asyncWorker(arg): Promise { console.log(await arg) }

output- True (after 1 second)

mcollina commented 3 years ago

I'm sorry but I do not have enough time to explain this. I would say that you probably do not need this module and using await is more than enough for you.