mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-26 21:23:53 +03:00
22 lines
518 B
Idris
22 lines
518 B
Idris
|
-- Idris2
|
||
|
|
||
|
import System
|
||
|
import System.Concurrency
|
||
|
|
||
|
-- Test that acquiring the mutex in the parent, then the child blocks correctly
|
||
|
main : IO ()
|
||
|
main =
|
||
|
do m <- makeMutex
|
||
|
mutexAcquire m
|
||
|
putStrLn "Main acquired mutex"
|
||
|
t <- fork $ do mutexAcquire m
|
||
|
putStrLn "Child acquired mutex"
|
||
|
sleep 2
|
||
|
mutexRelease m
|
||
|
putStrLn "Child released mutex"
|
||
|
sleep 1
|
||
|
mutexRelease m
|
||
|
putStrLn "Main released mutex"
|
||
|
threadWait t
|
||
|
|