impress icon indicating copy to clipboard operation
impress copied to clipboard

Improve thread pool invocation

Open tshemsedinov opened this issue 3 years ago • 2 comments

New syntax:

const result = await domain.module1
  .doSomething(args)
  .thread({ exclusive: true });

tshemsedinov avatar Sep 19 '21 19:09 tshemsedinov

Questions:

  • If we do a wrapper for all domain and lib functions that will force us to use async/await syntax everywhere. Should we wrap all functions to thenable in our case (similar wrapper Procedure has been done for api)?
  • How are we supposed to keep some function unwrapped with this syntax?
  • Thenable is not a Promise. How we are supposed to distinguish thenable and promise?

Example:

We have sync function here let it be lib/array/timesTen.js

(array) => array.map((el) => el*10)

If I want to just invoke this function inside my code that will look like this:

async ({ array }) => {
  return await lib.array.timesTen(array);
}

georgolden avatar Oct 19 '21 13:10 georgolden

We will wrap just async functions, to call timesTen from another thread you need async (array) => array.map((el) => el * 10)

tshemsedinov avatar Oct 19 '21 17:10 tshemsedinov