Skip to content

Commit

Permalink
threads: print to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-martin committed Jul 30, 2019
1 parent 961968c commit 9c9f266
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions outputs/threads.txt
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
main: 1
main: 2
main: 3
...
...
...
...
...
...
done
4 changes: 2 additions & 2 deletions threads.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import System.IO

main =
do
hSetBuffering stderr LineBuffering
hSetBuffering stdout LineBuffering

tasksCompleted <- atomically (newTVar 0)

let
task x =
do
for_ [1..3] $ \i ->
hPutStrLn stderr (x ++ ": " ++ show i)
putStrLn (x ++ ": " ++ show i)
atomically $
modifyTVar' tasksCompleted (+ 1)

Expand Down
2 changes: 1 addition & 1 deletion tools/outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in
(run "hashing.txt" ../hashing.hs)
(run "hello-world.txt" ../hello-world.hs)
(run "mutable-references.txt" ../mutable-references.hs)
(run "threads.txt" ../threads.hs)
(run' "threads.txt" ../threads.hs { sed = ["s!^fork.*$!...!"]; })
(run "timeouts.txt" ../timeouts.hs)
(run' "transactions.txt" ../transactions.hs { sed = ["s!\\[.*\\]!...!"]; })
(run "variables.txt" ../variables.hs)
Expand Down

0 comments on commit 9c9f266

Please sign in to comment.