[Haskell] Re: Network accept loop with graceful shutdown implementation

Simon Marlow simonmarhaskell at gmail.com
Fri Dec 8 04:49:27 EST 2006


Taral wrote:
> On 12/7/06, Chris Kuklewicz <haskell at list.mightyreason.com> wrote:
> 
>> 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.
> 
> 
> I think people are misunderstanding the nature of a safepoint. The
> safepoint is a point at which you are prepared to have exceptions
> delivered. This does not mean that they *will* be delivered, just that
> they can. If you need to *wait* for an asynchronous exception, then
> you shouldn't be using them at all.

Right.  If a thread mostly runs inside 'block' with the occasional safe point, 
then your exceptions are not really asynchronous, they're synchronous.

In this case, I'd say a better solution is to have an explicit event queue, and 
instead of the safe point take an event from the queue.  The action on receiving 
an event can be to raise an exception, if necessary.

Cheers,
	Simon


More information about the Haskell mailing list