Slideshow transcript
Slide 1:Concurrent and Multicore Haskell
Slide 2: Concurrent Haskell • For responsive programs that multitask • Plain old threads, with a few twists • Popular programming model
Slide 3: A simple example backgroundWrite path contents = done <- newEmptyMVar forkIO $ do writeFile path contents putMVar done () return done
Slide 4: Imperative code!? • Threads, assignment, “return”... huh? • Haskell is a multi-paradigm language • Pure by default • Imperative when you need it
Slide 5: What’s an MVar? • An atomic variable • Either empty or full • takeMVar blocks if empty • putMVar blocks if full • Nice building block for mutual exclusion
Slide 6: Coding with MVars • Higher-order programming • modifyMVar: atomic modification • Safe critical sections • Combine MVars into a list



Add a comment on Slide 1
If you have a SlideShare account, login to comment; else you can comment as a guest- Favorites & Groups
Showing 1-50 of 2 (more)