[Haskell-cafe] Optimizing a high-traffic network architecture

Tomasz Zielonka tomasz.zielonka at gmail.com
Thu Dec 15 04:39:15 EST 2005


On Thu, Dec 15, 2005 at 09:32:38AM +0000, Joel Reymont wrote:
> Well, my understanding is that once I do a takeMVar I must do a  
> putMVar under any circumstances. This is why I was blocking checkTimers.

Perhaps you could use modifyMVar:

http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-MVar.html#v%3AmodifyMVar

  modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()

  A safe wrapper for modifying the contents of an MVar. Like withMVar,
  modifyMVar will replace the original contents of the MVar if an
  exception is raised during the operation.

  modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b

  A slight variation on modifyMVar_ that allows a value to be returned (b)
  in addition to the modified value of the MVar.

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland


More information about the Haskell-Cafe mailing list