Skip to content
README.md 610 B
Newer Older
# io-thread-pool
Yuanle Song's avatar
Yuanle Song committed

use a thread pool to execute IO actions.

Usage:

- add io-thread-pool as dependencies (package.yaml or .cabal file).

- create a thread pool with size n
  ```haskell
  newTask :: Int -> IO (Task a)
  pool <- newTask n
  ```

- add job to the pool
  ```haskell
  addTask :: Task a -> IO a -> IO ()
  addTask pool someIO
  ```

- add many jobs to the pool
  ```haskell
  addTasks :: Task a -> [IO a] -> IO ()
  addTasks pool $ map someIO [someParam1, someParam2, someParam3]
  ```

- fetch result so far
  ```haskell
  getTaskResults :: Task a -> IO [a]
  results <- getTaskResults pool
  ```