bos/pool — pull request #15 by kim (2013-11-12 18:28:18+00:00)
Title: Prevent the finalizer to run early

According to the [documentation](http://hackage.haskell.org/package/base-4.6.0.1/docs/System-Mem-Weak.html#t:Weak), using `addFinalizer` on an "ordinary non-primitive Haskell type" may cause the finalizer to run earlier than expected, due to the compiler being "free to optimise away or duplicate the underlying data structure".

This is reproducibly happening in our code, which uses `resource-pool` in `snap`-based web applications (both directly and transitively eg. by using [hedis](http://hackage.haskell.org/package/hedis)). The result is that the `reaper` thread gets killed immediately and idle resources never get freed.

I haven't been able to track down why exactly this is happening only in this context (using `resource-pool` "standalone" seems to work fine), but the attached patch fixes the issue.