https://github.com/nh2/haskell-sharedio
Bundles shared calls to IO functions to perform them only once
https://github.com/nh2/haskell-sharedio
Last synced: 3 months ago
JSON representation
Bundles shared calls to IO functions to perform them only once
- Host: GitHub
- URL: https://github.com/nh2/haskell-sharedio
- Owner: nh2
- Created: 2013-09-18T11:04:08.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-10T02:03:58.000Z (over 11 years ago)
- Last Synced: 2025-02-13T13:05:07.708Z (4 months ago)
- Language: Haskell
- Size: 141 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
haskell-sharedio
================Allows "bundling" or "throttling" of concurrent IO to perform computation
only once.Useful in situations where concurrency can be expensive, such as file
system scans (where concurrent execution usually returns the same
result but introduces much disk seeking overhead).Example
-------```haskell
import Control.Concurrent.SharedIO (SharedIO, newSharedIO, withSharedIO)-- A webserver that lists directory contents, using
-- SharedIO to bundle clients fanatically hitting refresh.-- Without this, the file seeking would slow the server to a crawl.
main = do
fileScanSharedIO <- newSharedIO
runWebserver (handleRequest fileScanSharedIO)handleRequest :: SharedIO -> IO [FilePath]
handleRequest fileScanSharedIO = do
withSharedIO fileScanSharedIO (getDirectoryContents "largefolder")
```