-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Concurrent resource map -- -- Please see the README on GitHub at -- https://github.com/Fuuzetsu/concurrent-resource-map#readme @package concurrent-resource-map @version 0.1.0.0 module Data.ConcurrentResourceMap -- | A map of shared resources r keyed by k. data ConcurrentResourceMap k r -- | Create an empty resource map. newResourceMap :: Ord k => IO (ConcurrentResourceMap k r) -- | Use a resource that can be accessed concurrently via multiple threads -- but is only initialised and destroyed on as-needed basis. If number of -- users falls to 0, the resource is destroyed. If a new user joins and -- resource is not available, it's created. -- -- Calls to withSharedResource can even be nested if you need -- access to resources with different keys in the same map. Calling -- withSharedResource in a nested matter on same resource key -- should have no real adverse effects either. withSharedResource :: Ord k => ConcurrentResourceMap k r -> k -> IO r -> (r -> IO ()) -> (r -> IO a) -> IO a