Skip to content

when(fulfilled:…) should be able to resolve synchronously #52

@lilyball

Description

@lilyball

The when(fulfilled:…) family takes a QoS and does all of its work there. The downside here is it can't resolve synchronously even if all inputs have resolved. By contrast, when(first:cancelRemaining:) will resolve synchronously if any of the inputs have fulfilled/rejected.

Implementation note: One solution is to use .nowOr(_:) (see #34) on the interior work. We can then test the group to see if it's ready synchronously. We could also rewrite the enqueue loop to only hop on the context if it's rejecting/cancelling, because writing to resultBuffer can happen on any thread. Note that in this case we can still do the group.leave() outside of the context, as the resultBuffer entry will be nil and thus our processing of the buffer will safely abort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions