No I meant Channels (from Data.Concurrent)... you can use a structure like:

   data Command = Read FileAddr (MVar MyData) | Write FileAddr MyData

So to write you just do:

   writeChan iochan (Write address data) -- returns immediately
   -- write happens asynchronously later

and to read:

   data <- newEmptyMVar
   writeChan iochan (Read address data) -- read not happend yet.
   myData <- readMVar data -- blocks until read completes.

The forked thread (with forkIO) just reads the commands form the "iochan"
and processes them one at a time.

   Keean

Ketil Malde wrote:

Keean Schupke <[EMAIL PROTECTED]> writes:



At the end of the day IO is serial by nature (to one device anyway),
so the way to do this into one file is to have one thread that reads
and writes, and to 'send' read and write requests over channels from
the threads that need the work done



Would the stream proposal make this possible and easy? I.e. could the IO thread provide (say) output streams to the other threads, and pass writes on to its own output stream?

-kzm



_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to