data-concurrent-queue (empty) → 0.1.0.0
raw patch · 4 files changed
+104/−0 lines, 4 filesdep +basedep +stmsetup-changed
Dependencies added: base, stm
Files
- Data/Concurrent/Queue.hs +58/−0
- LICENSE +20/−0
- Setup.hs +2/−0
- data-concurrent-queue.cabal +24/−0
+ Data/Concurrent/Queue.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-}+module Data.Concurrent.Queue (TakeQueue(..), PutQueue(..), Take, Put, TakePut, DMVar, newDMVar, newEmptyDMVar) where++import Control.Concurrent+import Control.Concurrent.STM+import Control.Applicative++class TakeQueue q m | q -> m where+ take :: q a -> m a++class PutQueue q m | q -> m where+ put :: q a -> a -> m ()++instance TakeQueue MVar IO where+ take = takeMVar+instance PutQueue MVar IO where+ put = putMVar++instance TakeQueue Chan IO where+ take = readChan+instance PutQueue Chan IO where+ put = writeChan++instance TakeQueue TMVar STM where+ take = takeTMVar+instance PutQueue TMVar STM where+ put = putTMVar+++newtype Take = Take Take+newtype Put = Put Put+newtype TakePut = TakePut TakePut++newtype DMVar d a = DMVar (MVar a)++newDMVar :: a -> IO (DMVar d a)+newDMVar a = DMVar <$> newMVar a++newEmptyDMVar :: IO (DMVar d a)+newEmptyDMVar = DMVar <$> newEmptyMVar++takeDMVar :: DMVar d a -> IO a+takeDMVar (DMVar x) = takeMVar x++putDMVar :: DMVar d a -> a -> IO ()+putDMVar (DMVar x) a = putMVar x a+++instance TakeQueue (DMVar TakePut) IO where+ take = takeDMVar+instance PutQueue (DMVar TakePut) IO where+ put = putDMVar++instance TakeQueue (DMVar Take) IO where+ take = takeDMVar++instance PutQueue (DMVar Put) IO where+ put = putDMVar
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2014 George Rogers++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ data-concurrent-queue.cabal view
@@ -0,0 +1,24 @@+-- Initial data-concurrent-queue.cabal generated by cabal init. For +-- further documentation, see http://haskell.org/cabal/users-guide/++name: data-concurrent-queue+version: 0.1.0.0+synopsis: A Library for directional queues+-- description: +license: MIT+license-file: LICENSE+author: George Rogers+-- maintainer: +-- copyright: +category: Concurrency+build-type: Simple+-- extra-source-files: +cabal-version: >=1.10++library+ exposed-modules: Data.Concurrent.Queue+ -- other-modules: + other-extensions: MultiParamTypeClasses, FunctionalDependencies+ build-depends: base >=4.5 && <4.6, stm >=2.4 && <2.5+ -- hs-source-dirs: + default-language: Haskell2010