I have a promise / pending mood for my web worker, where the main thread modifies the web worker data and tells me to recount. I have a promise to return it after completion.
However, in the middle of the process, the main thread may make additional changes, again with a promise to call back upon completion. (This interrupt may occur because the web worker sometimes calls setTimeout to resolve the breaks.) At this point, the web worker holds 2 promises in the main thread, both of which will return the same value.
Is it possible to refuse the first promise and only call back on the second. The code will work fine, and the logic of the main thread will be excellent (actually better) with one callback. Are there any problems with this?
A promise is just a function stored in an object that I hold in a hash table. Therefore, if I delete it from the hash table, its memory must be returned to the heap and therefore there should be no leaks.
So, can I make my callback system a liar (if necessary)?
source
share