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
Reinier Maas
GHC
Commits
12846b85
Commit
12846b85
authored
4 years ago
by
Andreas Klebinger
Committed by
Ben Gamari
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
winio: Update IOPort haddocks.
parent
bd6b8ec1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/base/GHC/IOPort.hs
+16
-8
16 additions, 8 deletions
libraries/base/GHC/IOPort.hs
with
16 additions
and
8 deletions
libraries/base/GHC/IOPort.hs
+
16
−
8
View file @
12846b85
...
...
@@ -21,6 +21,9 @@
-- It gives us the ability to have one thread to block, wait for a result from
-- another thread and then being woken up. *Nothing* more.
--
-- This type is very much GHC internal. It might be changed or removed without
-- notice in future releases.
--
-----------------------------------------------------------------------------
module
GHC.IOPort
(
...
...
@@ -53,16 +56,23 @@ for communication between concurrent threads, where one of the threads is
controlled by an external state. e.g. by an I/O action that is serviced by the
runtime. It can be thought of as a box, which may be empty or full.
It is mostly similar to the behavior of MVar except writeIOPort doesn't block if
the variable is full and the GC won't forcibly release the lock if it thinks
It is mostly similar to the behavior of 'Control.Concurrent.MVar.MVar'
except 'writeIOPort' doesn't block if the variable is full and the GC
won't forcibly release the lock if it thinks
there's a deadlock.
The properties of IOPorts are:
* Writing to an empty IOPort will not block.
* Writing to an full IOPort will not block
and
throw an exception.
* Reading from an IOPort for the second time
will
throw an exception.
* Writing to an full IOPort will not block
. It might
throw an exception.
* Reading from an IOPort for the second time
might
throw an exception.
* Reading from a full IOPort will not block, return the value and empty the port.
* Reading from an empty IOPort will block until a write.
* Reusing an IOPort (that is, reading or writing twice) is not supported
and might throw an exception. Even if reads and writes are
interleaved.
This type is very much GHC internal. It might be changed or removed without
notice in future releases.
-}
...
...
@@ -89,18 +99,16 @@ newIOPort value =
-- |Atomically read the the contents of the 'IOPort'. If the 'IOPort' is
-- currently empty, 'readIOPort' will wait until it is full. After a
-- 'readIOPort', the 'IOPort' is left empty.
-- TODO: Figure out how to make this an exception for better debugging.
--
-- There is one important property of 'readIOPort':
--
-- * Only a single threads can be blocked on an 'IOPort', The second thread
-- attempting to block will be silently ignored.
-- * Only a single threads can be blocked on an 'IOPort'.
--
readIOPort
::
IOPort
a
->
IO
a
readIOPort
(
IOPort
ioport
#
)
=
IO
$
\
s
#
->
readIOPort
#
ioport
#
s
#
-- |Put a value into an 'IOPort'. If the 'IOPort' is currently full,
-- 'writeIOPort' will
return False and not block
.
-- 'writeIOPort' will
throw an exception
.
--
-- There is one important property of 'writeIOPort':
--
...
...
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