[Haskell-cafe] MVar considered harmful

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Fri Dec 28 23:06:41 UTC 2018


Dear Viktor,

Viktor Dukhovni wrote:
> > On Dec 28, 2018, at 12:44 PM, Bertram Felgenhauer via Haskell-Cafe <haskell-cafe at haskell.org> wrote:
> > This is awkward to fix. Basically, when abandoning the lock before it
> > has been released by the previous owner, we need a new thread to wait
> > for the 'current' IVar and notify the 'next' one, since the current
> > thread is being interrupted.
> 
> I think that work can be delegated to the waiting thread, by making
> locks (really barriers) optionally chain to a parent barrier that
> also needs to be waited for (recursively).  This is cheap, [...]

Thanks! Using the next waiting thread for cleanup work instead of
spawning a fresh one is much more elegant indeed.

Cheers,

Bertram


More information about the Haskell-Cafe mailing list