Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinct TVarIds for various TVar roles #177

Merged
merged 2 commits into from
Oct 6, 2024
Merged

Distinct TVarIds for various TVar roles #177

merged 2 commits into from
Oct 6, 2024

Conversation

coot
Copy link
Collaborator

@coot coot commented Oct 4, 2024

TVars are used to emulate TMVars and MVars and a few other shared variables, and thus can have
many different roles. For each role TVarId provides a constructor,
which makes it easier to distinguish them in a trace.

  • TVar
  • TMVar
  • MVar
  • TQueue
  • TBQueue
  • TSem
  • TChan - left as a todo.
ex0 :: IOSim s ()
ex0 = do
    atomically $ newTVar ""
    return ()

ex1 :: IOSim s ()
ex1 = do
    atomically $ newTMVar ""
    return ()

ex2 :: IOSim s ()
ex2 = do
    newEmptyMVar
    return ()
λ putStrLn  $ ppTrace $ runSimTrace ex0
0s - Thread []   main - TxCommitted [] [TVarId 0]
0s - Thread []   main - Unblocked []
0s - Thread []   main - Deschedule Yield
0s - Thread []   main - ThreadFinished
0s - Thread []   main - MainReturn () []
λ putStrLn  $ ppTrace $ runSimTrace ex1
0s - Thread []   main - TxCommitted [] [TMVarId 0]
0s - Thread []   main - Unblocked []
0s - Thread []   main - Deschedule Yield
0s - Thread []   main - ThreadFinished
0s - Thread []   main - MainReturn () []
λ putStrLn  $ ppTrace $ runSimTrace ex2
0s - Thread []   main - TxCommitted [] [MVarId 0]
0s - Thread []   main - Unblocked []
0s - Thread []   main - Deschedule Yield
0s - Thread []   main - ThreadFinished
0s - Thread []   main - MainReturn () []

@coot coot marked this pull request as draft October 4, 2024 10:38
@coot coot requested a review from jasagredo October 4, 2024 10:38
@coot coot force-pushed the coot/labelmvar branch 2 times, most recently from 2dcdc97 to 27e22ce Compare October 4, 2024 10:53
Copy link
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@coot coot marked this pull request as ready for review October 4, 2024 10:58
@coot coot force-pushed the coot/labelmvar branch 2 times, most recently from d625d22 to 66ab064 Compare October 6, 2024 07:12
@coot
Copy link
Collaborator Author

coot commented Oct 6, 2024

I pushed some stylistic & haddock changes.

@coot coot enabled auto-merge October 6, 2024 07:13
@coot coot added documentation Improvements or additions to documentation trace Issues / PRs related to IOSim trace labels Oct 6, 2024
coot added 2 commits October 6, 2024 22:31
`TVar`s are used to emulate `TMVar`s and `MVar`s, and thus can have
three different roles.  For each role `TVarId` provides a constructor,
which makes it easier to distinguish them in the trace.
@coot coot added this pull request to the merge queue Oct 6, 2024
Merged via the queue into main with commit fc24459 Oct 6, 2024
20 checks passed
@coot coot deleted the coot/labelmvar branch October 6, 2024 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation trace Issues / PRs related to IOSim trace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants