-
Notifications
You must be signed in to change notification settings - Fork 361
Open
Labels
Description
Calling a function like this in two separate threads will result in the second thread being blocked from running until first thread callback is hit.
var wrapper = async function(time, callback){`
console.log('start');
setTimeout(function(){
console.log('end');
callback('hit');
}, time);
};
interpreter.setProperty(globalObject, 'await',
interpreter.createAsyncFunction(wrapper));
If I call await(2000)
in both threads and run them simultaneously, I expect to see 'start' printed simultaneously. Instead the first 'start' will be printed followed by 'end' and then the second 'start' will be printed.
Should it be possible in theory to achieve this? If so, any suggestions are appreciated! Perhaps I am approaching this from the wrong angle or there is a workaround I have not considered.
Thanks!