Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The author here. Just opened HN and saw that my library is on the front page . If you have any questions, I can answer them.


Have you benchmarked the overhead of awaiting? I believe that in doing so you yield to the microtask queue and then your function has to be scheduled and run again. You could compare

        await yieldOrContinue('user-visible');
        doSomeWork();
against

        if (isTimeToYield('user-visible')) {
            await yieldControl('user-visible');
        }
        doSomeWork();
A few years back when I measured it on a fast laptop the cost was ~1µs to do `await 0;`


I haven't. I should do that. Many people are talking about this and this makes me think I should measure and talk about it in the readme. Thanks!


How does this differ from cooperative multi tasking?


If I'm reading this correctly, this is a library for use within a browser, in which case the answer is that this makes it easier to live within the constraints of the browser, which has arguably the strangest "multitasking" support anywhere, what with all the constraints it had to satisfy to be added in to an architecture already 15 years old at that point.


Yeah, that sums it up. The library tries to use the single thread the browser UI is running on and just not freeze it.


Hi, forgive me if I missed it, I just briefly browsed the repo. Does the library itself handle cancellation, or would user code be responsible for that?


This is on my list. I want to provide a `signal` property to enable easier and more efficient cancellation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: