From 73073ea6a425ac3a521f9eaafc354533d70532ce Mon Sep 17 00:00:00 2001 From: Yuanle Song Date: Tue, 23 Apr 2019 19:45:22 +0800 Subject: [PATCH] update README.md file --- README.md | 30 ++++++++++++++++++++++++++++++ package.yaml | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 58ad263..b9cfe1a 100644 --- a/README.md +++ b/README.md @@ -1 +1,31 @@ # io-thread-pool + +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 + ``` diff --git a/package.yaml b/package.yaml index f38e1db..e9d86d3 100644 --- a/package.yaml +++ b/package.yaml @@ -4,7 +4,7 @@ github: "sylecn/io-thread-pool" license: BSD3 author: "Yuanle Song" maintainer: "sylecn@gmail.com" -copyright: "Copyright: (c) 2018 Yuanle Song" +copyright: "Copyright: (c) 2018, 2019 Yuanle Song" extra-source-files: - README.md @@ -17,7 +17,7 @@ extra-source-files: # To avoid duplicated efforts in documentation and dealing with the # complications of embedding Haddock markup inside cabal files, it is # common to point users to the README.md file. -description: Please see the README on GitHub at +description: Please see the README at ghc-options: - -Wall -- GitLab