mozilla/rust — pull request #7392 by sstewartgallus (2013-06-25 23:22:44+00:00)
Title: Added method to unpoison poisoned RWARCs

This is mostly a prototype for future changes. I assume more
complicated methods like unpoison_with_condvar may need to be added
but the whole complicated mess of varying types of writes, and reads
need to be refactored, and turned into a cleaner, and better interface
anyways. Personally, I need this operation to implement functions for
the library of concurrent data structures I am working on but this
operation may be of interest to others.

A rustic style for cleaning up the interface is unclear to me at the
moment but a possible example in Haskell might be to use a monad, and
have write simply be a consequence of the logically more primitive
read, and unpoison operations. This monadic approach in Haskell might
look like the following:

atomicIncrement var = atomically $ do
x <- read var
var $= x + 1