| ... | ... | @@ -25,19 +25,6 @@ Papers and other docs: |
|
|
|
- [ A Draft report addendum](http://www.haskell.org/ghc/docs/papers/threads.ps.gz) (a shorter version of the above paper).
|
|
|
|
- [ Software Transactional Memory](http://research.microsoft.com/~simonpj/papers/stm/)
|
|
|
|
|
|
|
|
## Pros
|
|
|
|
|
|
|
|
|
|
|
|
- Vital for some modern applications and large applications commonly require it.
|
|
|
|
- Stable `MVar` implementation is well understood and tested.
|
|
|
|
|
|
|
|
## Cons
|
|
|
|
|
|
|
|
|
|
|
|
- Imposes non trivial implementation constraints.
|
|
|
|
- Providing a 'select' and non-blocking IO would be enough to allow people to implement something like it themselves in haskell and are provided by most systems as primitives.
|
|
|
|
- Things like the 'poor man's concurrency monad' can achieve some of the benefits
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
| ... | ... | @@ -51,8 +38,10 @@ Papers and other docs: |
|
|
|
At least the following interface will be provided
|
|
|
|
|
|
|
|
|
|
|
|
- Control.Concurrent.MVar - everything except addMVarFinalizer
|
|
|
|
- Control.Concurrent - ThreadId?,myThreadId,forkIO,yield,threadWaitRead\[1\],threadWaitWrite\[1\],threadDelay
|
|
|
|
- [ Control.Concurrent.MVar](http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-MVar.html) - everything except `addMVarFinalizer`
|
|
|
|
- [ Control.Concurrent](http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html) - `ThreadId`, `myThreadId`, `forkIO`, `yield`, `sleep` (replaces `threadDelay`).
|
|
|
|
- `Control.Concurrent.Chan`, `Control.Concurrent.QSem`, `Control.Concurrent.QSemN`,
|
|
|
|
`Control.Concurrent.SampleVar`
|
|
|
|
|
|
|
|
|
|
|
|
the FFI must be able to handle 'concurrent nonrentrant' imports, but not
|
| ... | ... | @@ -101,21 +90,24 @@ perhaps a better phrasing of the first proposal exists, in practice, from a user |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yield is guarenteed to choose an alternate thread if another one exists and is
|
|
|
|
`yield` is guarenteed to choose an alternate thread if another one exists and is
|
|
|
|
runnable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
threadDelay guarentees the thread will wait as long as its argument at a
|
|
|
|
`sleep` guarentees the thread will wait as long as its argument at a
|
|
|
|
minimum. it may be blocked for longer.
|
|
|
|
|
|
|
|
|
|
|
|
## notes
|
|
|
|
## I/O
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
I/O operations from `System.IO`, `System.Directory`, `System.Process` (and others?) do not prevent other threads from making progress when they are waiting for I/O to complete.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\[1\] may be moved to another module (Control.Concurrent.IO?) , routines working on Handles should be
|
|
|
|
added too.
|
|
|
|
We could provide a lower-level non-blocking I/O interface along the lines of `threadWaitRead`, `threadWaitWrite`, perhaps in `Control.Concurent.IO`.
|
|
|
|
|
|
|
|
|
|
|
|
# Optional extensions to basic standard
|
| ... | ... | |