| ... | ... | @@ -38,7 +38,10 @@ Papers and other docs: |
|
|
|
- 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
|
|
|
|
|
|
|
|
## Proposal
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
# Proposal
|
|
|
|
|
|
|
|
|
|
|
|
- Standardise on Concurrent Haskell without STM. It is our view that even in the presence of STM, `MVar`s offer
|
| ... | ... | @@ -50,18 +53,42 @@ Papers and other docs: |
|
|
|
|
|
|
|
- Use the semantics from [ Extending the Haskell FFI with Concurrency](http://www.haskell.org/~simonmar/papers/conc-ffi.pdf)
|
|
|
|
|
|
|
|
- Standardise a way to write thread-safe libraries that work with implementations that don't provide full concurrency support.
|
|
|
|
|
|
|
|
Questions:
|
|
|
|
## Questions
|
|
|
|
|
|
|
|
|
|
|
|
- Decide how much pre-emption is acceptable, and figure out how to specify this.
|
|
|
|
- Decide whether the Haskell' report includes Concurrency (with a separate NoConcurrency addendum to specify how implementations without concurrency behave), or whether Concurrency is specified in a separate addendum.
|
|
|
|
|
|
|
|
- Should we specify what an implementation that doesn't provide concurrency should do? (e.g. provide an implementation
|
|
|
|
of MVars in terms of IORefs, so that concurrency-safe libraries can be written portably).
|
|
|
|
- Decide how much pre-emption is acceptable, and figure out how to specify this.
|
|
|
|
|
|
|
|
- Require bound thread support, or make it optional? (YHC has concurrency with non-blocking foreign calls, but doesn't
|
|
|
|
have bound threads as yet.)
|
|
|
|
|
|
|
|
## Thread-safety
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In order to write library code that is thread-safe when run in a multi-threaded environment, two things are needed:
|
|
|
|
|
|
|
|
|
|
|
|
1. a way to protect mutable state against race conditions
|
|
|
|
1. a way to declare that foreign calls are blocking
|
|
|
|
|
|
|
|
|
|
|
|
For (1), we have two choices:
|
|
|
|
|
|
|
|
|
|
|
|
- Provide `MVar`s. A non-concurrent implementation might implement them in terms of `IORef`,
|
|
|
|
for example.
|
|
|
|
|
|
|
|
- Provide STM. Not entirely trivial to implement, even in a single-threaded implementation, because
|
|
|
|
exceptions have to abort a transaction.
|
|
|
|
|
|
|
|
|
|
|
|
For (2), one option is [ForeignBlocking](foreign-blocking).
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
| ... | ... | |