Skip to content

Figure out if a thread is alive in io-classes #227

Open

Description

@MaximilianAlgehed

Is your feature request related to a problem? Please describe.
With the removal of threadStatus support there is no way to figure out, to my best understanding, if a thread is alive or not.

Describe the solution you'd like
Since threadStatus has some issues in GHC, could we perhaps add something like isAlive :: ThreadId -> Bool which should have much clearer semantics?

Describe alternatives you've considered
Not being able to know if a part of your system is alive?

Additional context
This is usually possible in multi-threaded systems you'd like to model with io-sim...

Are you willing to implement it?

  • Are you? 😃

Activity

  1. added
    enhancement
    on Oct 15, 2025
  2. MaximilianAlgehed commented on Oct 15, 2025

    @MaximilianAlgehed
    ContributorAuthor

    On a more serious note, this should be relatively straight-forward to implement without bumping into any of the really nasty bugs in GHC that caused this to be problematic before. For IO we should be able to do:

    isAlive :: ThreadId -> IO Bool
    isAlive tid = (`notElem` [ThreadFinished, ThreadDied]) <$> threadStatus tid
  3. coot commented on Oct 28, 2025

    @coot
    Collaborator

    The tricky part is to implement it in a way that IOSimPOR can discover races, e.g. if one thread is scheduled before the monitoring one, the monitoring one can receive a different result and thus land in a different execution branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions