[Haskell-cafe] Re: Memory and Threads - MVars or TVars
gue.schmidt at web.de
Wed Jul 28 21:17:33 EDT 2010
I'm right now approaching the subject of concurrency myself for the
first time in an application that spiders web pages.
The getting the web pages part via http request is the one that is time
consuming and thus the one that I wish to "concurrentalize", ie. getting
up to 6 six pages concurrently at a time.
From what I've learned so far it seems that there are the following
approaches to concurrency in haskell:
1. use a primitive approach with the concurrency primitives that haskell
/ ghc provides, ie. locks, MVars, TVars etc. directly
2. use one abstraction level up, ie. use STM (Software Transactional
Memory), there is a chapter in RWH about it.(also available online).
3. use yet another abstraction level up by using the orc library from
the galois people, available on hackage. Documentation to this one is a
paper available on the galois website. I am currently at the very
beginning of familiarizing myself with this approach but it seems the
most feasible way to do concurrency. Using this approach is pretty much
like not having to worry about garbage collection. Even using STM you
still have to do a lot of your own manual forkIO, putVar, kill etc.
Am 29.07.10 02:23, schrieb Eitan Goldshtrom:
> Hi everyone. I was wondering if someone could just guide me toward some
> good information, but if anyone wants to help with a personal
> explanation I welcome it. I'm trying to write a threaded program and I'm
> not sure how to manage my memory. I read up on MVars and they make a lot
> of sense. My real question is what is "atomic" and how does it apply to
> TVars? I don't understand what atomic transactions are and I can't seem
> to find a concise explanation. I also saw some stuff about TMVars? But I
> can't find much on them either. Any help would be appreciated.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe