[Haskell-cafe] Killer pickler combinators (was Time leak)

Joel Reymont joelr1 at gmail.com
Wed Dec 21 10:15:56 EST 2005


Cale is a genius! This totally solves the timeouts.

Why, though? The lock is only used at the end of the unpickling. Why  
does it help?

On Dec 21, 2005, at 2:56 PM, Cale Gibbard wrote:

> By the way, when I was doing threadDelays, I meant:
> trace s = withMVar lock $ const $ threadDelay 20
> In case you didn't try that.
>
>  - Cale
>
> On 21/12/05, Joel Reymont <joelr1 at gmail.com> wrote:
>> I'm not sure I buy this. Again, this helps:
>>
>> {-# NOINLINE lock #-}
>> lock :: MVar ()
>> lock = unsafePerformIO $ newMVar ()
>>
>> trace s = withMVar lock $ const $ putStrLn s
>>
>> and then in read_
>>
>>         cmd <- read h trace
>>
>> trace is called _after_ all the timings in read so it should not
>> affect the timings.
>>
>> You could basically say that the lock is at the end of read, after
>> all the unpickling has been done. The other interesting thing is that
>> replacing trace with
>>
>> delay _ = threadDelay 1
>>
>> does not solve the issue.

--
http://wagerlabs.com/







More information about the Haskell-Cafe mailing list