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

Add TimeoutToken #3

Open
bergus opened this issue Sep 7, 2016 · 0 comments
Open

Add TimeoutToken #3

bergus opened this issue Sep 7, 2016 · 0 comments

Comments

@bergus
Copy link
Owner

bergus commented Sep 7, 2016

A token that is cancelled after a timeout is simple:

new CancelToken(cancel => setTimeout(cancel, t, "timeout"))

However, this keeps the setTimeout active even when the token is no longer needed and all promises that might be cancelled by it are already resolved. This could keep a process alive even when there's nothing to do any more.
Implement a TimeoutToken that does not need any resources while nobody is listening, i.e. simply stores the end time and calls setTimeout/clearTimeout as necessary.
In node, this also could be achieved by a simple unref call.

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

1 participant