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

feat(async/delay): add persistent option #2527

Merged
merged 6 commits into from
Aug 22, 2022
Merged

feat(async/delay): add persistent option #2527

merged 6 commits into from
Aug 22, 2022

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Aug 15, 2022

For #1730. Am I right in saying a test can't currently be done for this?

@0f-0b
Copy link
Contributor

0f-0b commented Aug 15, 2022

unrefTimer should probably be added to _deno_unstable.ts.

@kt3k
Copy link
Member

kt3k commented Aug 15, 2022

unrefTimer should probably be added to _deno_unstable.ts.

Right. Let's wrap it with type guard condition typeof Deno.unrefTimer == "function"

Also let's mention that the option depends on --unstable flag.

@kt3k
Copy link
Member

kt3k commented Aug 15, 2022

Another naming candidate for this option would be persistent (with opposite effect of boolean value) as used in fs.watch of node.js https://nodejs.org/api/fs.html#fswatchfilename-options-listener

Which do you think is better?

async/delay.ts Outdated
@@ -3,11 +3,13 @@

export interface DelayOptions {
signal?: AbortSignal;
/** Defines if the timer should be non-blocking. This is `false` by default. */
Copy link
Member

Choose a reason for hiding this comment

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

the timer should be non-blocking sounds strange to me as timers are always async operations. I would document this like Indicates whether the process can exit while the timer still existing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another naming candidate for this option would be persistent (with opposite effect of boolean value) as used in fs.watch of node.js https://nodejs.org/api/fs.html#fswatchfilename-options-listener

Which do you think is better?

Yeah, I like persistent.

@iuioiua iuioiua changed the title feat(async/delay): add unref option feat(async/delay): add persistent option Aug 15, 2022
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

@iuioiua Thanks for updating! Left one comment

async/delay.ts Outdated
Comment on lines 7 to 8
/** Indicates whether the process can exit before the timer ends. This is `false` by default. */
persistent?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

If we use persistent, then the meaning (effect) is the opposite of unref. The doc would be Indicates whether the process should continue to run as long as timer existing and it defaults to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My misunderstanding. Fixed now!

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

@kt3k
Copy link
Member

kt3k commented Aug 16, 2022

Let's wait a little while to see if there's any concern on this addition

@kt3k kt3k merged commit d7cd008 into denoland:main Aug 22, 2022
bartlomieju pushed a commit to bartlomieju/deno_std that referenced this pull request Aug 22, 2022
@iuioiua iuioiua deleted the feat(async/delay)-add-unref-option branch August 23, 2022 01:30
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

Successfully merging this pull request may close these issues.

3 participants