Skip to content

Add TimeoutToken #3

@bergus

Description

@bergus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions