Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the value of running it asynchronously? #47

Open
calvintwr opened this issue May 12, 2020 · 3 comments
Open

What's the value of running it asynchronously? #47

calvintwr opened this issue May 12, 2020 · 3 comments

Comments

@calvintwr
Copy link

if it's still using the main thread despite being made to run asynchronously, isn't it just the same as synchronous execution?

if so should you employ workers?

@bozzltron
Copy link
Owner

Synchronous execution would block the event loop. Async does not.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop

@calvintwr
Copy link
Author

Ah right. Thanks for the info.

@calvintwr
Copy link
Author

Actually I think async does come back to block the main thread after it has reached its turn. So just for the sake of OCD there’s 2 options:

  1. Fork a worker, but only a large enough JSON will benefit, in terms of freeing up the main thread. Otherwise it’s okay to live with a very brief period of blocking. Also when a worker posts the message, the main thread still needs to synchronously serialise. It’s possible to encode in the worker to Unint8array, then in the main thread, use a Coroutines parser.

  2. use coroutines for transforming objects in the main thread.

@calvintwr calvintwr reopened this Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants