[Haskell] Network accept loop with graceful shutdown
haskell at list.mightyreason.com
Thu Dec 7 07:35:00 EST 2006
Cat Dancer wrote:
> I have a prospective implementation of a network accept loop with
> graceful shutdown.
Could you add info about where to get your code (or the code) itself to the wiki
at http://haskell.org/haskellwiki/Concurrency_demos/Graceful_exit ?
> To avoid the "unlock (return ())" issue that Chris discovered, this
> implementation uses an additional MVar to indicate that a shutdown is
> in process. Thus (if the implementation is correct) the accept loop
> will shutdown either because of the MVar flag or by receiving the
> asynchronous exception inside of the 'accept'.
Small clarification: You don't need a safepoint in your code. But "unblock
yield" is the right code for a safepoint; the "unblock (return ())" suggested by
the published paper *does not work* in my small test, while "unblock yield"
worked every time in a small test. Simon may updated the documentation
eventually to reflect this.
> To address the issue that Chris noticed of a race condition that new
> threads cannot be started in a 'block' state, yet another MVar is set
> by the accept thread to indicate that it is now inside of a 'block'
> and is ready to receive the asynchronous exception.
More information about the Haskell