Skip to content
New issue

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

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

Already on GitHub? # to your account

Enable flush timing to be controlled from the host. #363

Merged
merged 1 commit into from
Mar 3, 2019

Conversation

rwjblue
Copy link
Collaborator

@rwjblue rwjblue commented Mar 2, 2019

  • Changes _autorun into a boolean
  • Adds a new flush option to the backburner options which allows the host to either immediately flush (which would equal the prior behavior) via microtasks, OR flush "sometime later"
  • Adds tests to ensure execution order

Paired with @krisselden

@rwjblue rwjblue force-pushed the allow-customized-flushing branch 2 times, most recently from fa627fc to 5ed02da Compare March 2, 2019 03:41
@@ -5,6 +5,14 @@ import lolex from 'lolex';
const SET_TIMEOUT = setTimeout;
let fakeClock;

function flushMicrotasks() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this flush macro task, as the promise wont resolve until setTimeout(resolve, 0)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s to ensure the current event frame’s microtask queue is flushed by resolving in a macro task

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that make sense @stefanpenner, I can rename if you'd prefer still just give me an alternate...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya, I understand what it does.

The name is off, it isn’t flush microtasks, it’s wait for some near future macro task.

Nothing prevents other unexpected work from sneaking in between so the “flush” word is misleading

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to change it, what would you like it to be named?

Some possibilities:

  • escapeMicrotaskQueue
  • stefsMagicalFutureMacroTask (😜)
  • waitForNextMacroTask

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I just renamed to escapeCurrentMicrotaskQueue which actually seems a bit more descriptive as well.

Copy link
Collaborator

@krisselden krisselden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spellcheck test names, precedence is spelled wrong.

@rwjblue rwjblue force-pushed the allow-customized-flushing branch 2 times, most recently from 79df7ea to 6986666 Compare March 2, 2019 20:00
@rwjblue
Copy link
Collaborator Author

rwjblue commented Mar 2, 2019

Fixed up linting failures and misspelling.

* Changes `_autorun` into a boolean
* Adds a new `flush` option to the backburner options which allows
  the host to either immediately flush (which would equal the prior
  behavior) via microtasks, **OR** flush "sometime later"
* Adds tests to ensure execution order

Co-authored-by: Kris Selden <kris.selden@gmail.com>
@rwjblue rwjblue force-pushed the allow-customized-flushing branch from 6986666 to a29d59e Compare March 2, 2019 20:28
@rwjblue rwjblue merged commit cfad13c into BackburnerJS:master Mar 3, 2019
@rwjblue rwjblue deleted the allow-customized-flushing branch March 3, 2019 16:36
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants