Copyright | (c) Alex Semin, 2015 |
---|---|
License | BSD3 |
Maintainer | alllex.semin@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Concurrent Bag data structure which is relying on STM for consistency in multi-threading environment. Bag (or Multi Set) is a data container which provides very efficient adding and removing but guarantees no order.
import Control.Concurrent.STM import qualified Data.STM.Bag as Bag main :: IO () main = do bag <- atomically $ (Bag.new :: STM (Bag.Impl Int)) atomically $ Bag.add bag 7 atomically $ Bag.add bag 5 x <- atomically $ Bag.take bag putStrLn $ show x -- x may be either 5 or 7