impress
impress copied to clipboard
Improve thread pool invocation
New syntax:
const result = await domain.module1
.doSomething(args)
.thread({ exclusive: true });
Questions:
- If we do a wrapper for all
domain
andlib
functions that will force us to use async/await syntax everywhere. Should we wrap all functions to thenable in our case (similar wrapperProcedure
has been done forapi
)? - 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);
}
We will wrap just async functions, to call timesTen from another thread you need
async (array) => array.map((el) => el * 10)