packages feed

write-buffer-stm (empty) → 0.1.0.0

raw patch · 6 files changed

+106/−0 lines, 6 filesdep +basedep +stmdep +stm-chanssetup-changed

Dependencies added: base, stm, stm-chans, write-buffer-core

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Author name here (c) 2017++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Author name here nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,3 @@+# write-buffer-stm++This library provides a function `writeBufferTBMQueue`, which allows you to chunk a `TBMQueue` with a bounded wait time per chunk.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Main.hs view
@@ -0,0 +1,5 @@+module Main where++main :: IO ()+main = do+  putStrLn "hello world"
+ src/WriteBuffer/STM/TBMQueue.hs view
@@ -0,0 +1,33 @@+module WriteBuffer.STM.TBMQueue+    ( module WriteBuffer.STM.TBMQueue+    , module X+    ) where++import           WriteBuffer                     as X++import           Control.Concurrent.STM+import           Control.Concurrent.STM.TBMQueue+import           Control.Monad.IO.Class++-- | This function takes a @'TBMQueue' a@ and yields a new @'TBMQueue' [a]@+-- which yields lists of the original inputs. The first parameter is the+-- bound of the output queue size -- the threads will block if this size is+-- reached and nothing is drawing from it. The second parameter is the+-- chunk size -- at most, this many elements will be in each output list.+-- The third parameter is the maximum amount of time to wait before+-- yielding a list.+writeBufferTBMQueue+    :: Int -- ^ The output queue bound+    -> Int -- ^ The chunk size for the output lists.+    -> Integer -- ^ The amount of time to wait in microseconds.+    -> TBMQueue a -- ^ The input queue.+    -> IO (TBMQueue [a])+writeBufferTBMQueue bound chunkSize i input = do+    output <- newTBMQueueIO bound+    let opts = (makeBufferOpts input (liftIO . atomically . writeTBMQueue output))+                { maxTimeToWait = i+                , maxBufferSize = chunkSize+                }+    runWriteBuffer opts+    pure output+
+ write-buffer-stm.cabal view
@@ -0,0 +1,33 @@+-- This file has been generated from package.yaml by hpack version 0.17.0.+--+-- see: https://github.com/sol/hpack++name:           write-buffer-stm+version:        0.1.0.0+synopsis:       A write buffer for STM channels and queues.+description:    See README.md+category:       Web+homepage:       https://github.com/parsonsmatt/write-buffer#readme+author:         Matt Parsons+maintainer:     parsonsmatt@gmail.com+copyright:      2017 Matt Parsons+license:        BSD3+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10++extra-source-files:+    README.md++library+  hs-source-dirs:+      src+  build-depends:+      base >= 4.7 && < 5+    , write-buffer-core+    , stm+    , stm-chans+  exposed-modules:+      Main+      WriteBuffer.STM.TBMQueue+  default-language: Haskell2010