Skip to content

Future.immediate() should still be async. #3356

Closed
@munificent

Description

@munificent

Currently, a future created using Future.immediate() will complete synchronously. That means code consuming futures has to be aware that operations that it chains of a future it receives may in fact run synchronously or they may do bad things.

For a concrete example, the unittest API will fail spectacularly if what it thinks is an async test completes synchronously.

To keep the semantics simple for consumers of futures, I believe they should always complete asynchronously. This means Future.immediate() should pump the message queue before completing.

If we do make this change, we should probably change the name of the constructor too, since it's no longer "immediate". I would either just use an unnamed constructor, or possibly "of": new Future.of(someValue);

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions