Skip to content

awaitAll shouldn't block forever if scoped is closing/closed #26

@mitchellwrosen

Description

@mitchellwrosen

Minor oversight: currently awaitAll will just block forever if called on a closing or closed scope.

If the scope is closed, we should just throw an exception.

If the scope is closing, then the user is doing something weird and wrong:

  • We know it's not the parent that's awaitAll-ing, since the parent is closing the scope.
  • It shouldn't be a child - calling awaitAll really never makes sense to call from a child thread on its own scope, since it (semantically) would just block forever. So, I think we should probably just block here, waiting for the TVar to become 0, which it won't, because we'll soon get hit by a ScopeClosing.
  • The third possibility, I suppose, is that the user has smuggled this Scope away to some non-child thread that's calling awaitAll. I kind of think it's ok to again just block forever here, waiting for the TVar to become 0, which it won't. If we eventually get hit by a BlockedIndefinitelyOnSTM, then ok.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions