Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
dad16373
Commit
dad16373
authored
24 years ago
by
Simon Marlow
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 2000-05-10 12:51:03 by simonmar]
Add tryTakeMVar test.
parent
72577aaf
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ghc/tests/concurrent/should_run/conc022.hs
+46
-0
46 additions, 0 deletions
ghc/tests/concurrent/should_run/conc022.hs
ghc/tests/concurrent/should_run/conc022.stdout
+1
-0
1 addition, 0 deletions
ghc/tests/concurrent/should_run/conc022.stdout
with
47 additions
and
0 deletions
ghc/tests/concurrent/should_run/conc022.hs
0 → 100644
+
46
−
0
View file @
dad16373
-- !!! test tryTakeMVar
import
Concurrent
import
Exception
import
IO
import
PrelIOBase
import
PrelConc
import
PrelGHC
main
=
do
m
<-
newEmptyMVar
r
<-
timeout
5
(
tryTakeMVar
m
)
(
putStrLn
"timed out!"
>>
return
Nothing
)
print
(
r
::
Maybe
Int
)
timeout
::
Int
-- secs
->
IO
a
-- action to run
->
IO
a
-- action to run on timeout
->
IO
a
timeout
secs
action
on_timeout
=
do
threadid
<-
myThreadId
timeout
<-
forkIOIgnoreExceptions
(
do
threadDelay
(
secs
*
1000000
)
raiseInThread
threadid
(
ErrorCall
"__timeout"
)
)
(
do
result
<-
action
killThread
timeout
return
result
)
`
catchAllIO
`
(
\
exception
->
case
exception
of
ErrorCall
"__timeout"
->
on_timeout
_other
->
do
killThread
timeout
throw
exception
)
forkIOIgnoreExceptions
::
IO
()
->
IO
ThreadId
forkIOIgnoreExceptions
action
=
IO
$
\
s
->
case
(
fork
#
action_plus
s
)
of
(
#
s1
,
id
#
)
->
(
#
s1
,
ThreadId
id
#
)
where
action_plus
=
catchAllIO
action
(
\
_
->
return
()
)
This diff is collapsed.
Click to expand it.
ghc/tests/concurrent/should_run/conc022.stdout
0 → 100644
+
1
−
0
View file @
dad16373
Nothing
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment