[Haskell-cafe] Concurrency questions

Felipe Lessa felipe.lessa at gmail.com
Sun Jan 6 06:41:37 EST 2008


On Jan 6, 2008 9:30 AM, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
> 2. I have a situation where I have a thread generating some data and
> putting it into a mutable array, and another thread trying to read that
> data. Is there a way I can make the reader thread block if it tries to
> read a cell that hasn't been computed yet, but not introduce too much
> overhead for cells that have been filled in?

If your thread fills the array linearly, you could maintain a variable
shared by those threads that say the last cell computed, and have the
read thread check that before reading. I think this wouldn't create
too much overhead, although it seems like there must be something
cleverer somewhere.

-- 
Felipe.


More information about the Haskell-Cafe mailing list