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

Investigate macroTasking #93

Open
jeswr opened this issue Sep 22, 2022 · 5 comments
Open

Investigate macroTasking #93

jeswr opened this issue Sep 22, 2022 · 5 comments

Comments

@jeswr
Copy link
Collaborator

jeswr commented Sep 22, 2022

Note to self for now:

See if we can remove macroTasking behavior - in particular see if we are able to do something like the following after fixing autoStart behavior

// Returns a function that asynchronously schedules a task
export function createTaskScheduler() : TaskScheduler {
  if (typeof queueMicrotask === 'function')
    return queueMicrotask;

  const r = Promise.resolve(undefined);
  return (task: Task) => { r.then(task) }
}
@rubensworks
Copy link
Collaborator

For reference, there's a long history behind this: #13

@RubenVerborgh
Copy link
Owner

RubenVerborgh commented Sep 23, 2022

Back in my days we used to DoEvents, my friends 👴
Also relevant is #29.

But given this history, shall we stick to the existing behavior, @jeswr?

@jeswr
Copy link
Collaborator Author

jeswr commented Sep 23, 2022

Most likely - but I would still like to leave this open to investigate. This is because issue of "As discovered in comunica/comunica#826, some use cases may lead to extensive microtask usages" may be resolved in https://github.com/RubenVerborgh/AsyncIterator/tree/breaking/v4 by doing things like ensuring that readable events can only be queued once per-tick per-iterator; and also skipping unecessary readable events on chained iterators.

@RubenVerborgh
Copy link
Owner

Gotcha; I do however think that:

  1. There might always exist long chains of events, which result in long event queues that need interrupting (just like long recursion can also always occur in synchronous programming)
  2. We might not want clients to bind on microtask semantics

But if we can conclusively disprove 1, then I'm happy to go ahead.

@RubenVerborgh
Copy link
Owner

Actually the more relevant issue is #17 (comment), sorry. #29 only changed the kind of macrotask.

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

3 participants