packages feed

unagi-chan 0.4.1.0 → 0.4.1.1

raw patch · 5 files changed

+55/−15 lines, 5 filesdep ~primitivePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: primitive

API changes (from Hackage documentation)

- Control.Concurrent.Chan.Unagi.NoBlocking: Next :: a -> (Stream a) -> Next a
+ Control.Concurrent.Chan.Unagi.NoBlocking: Next :: a -> Stream a -> Next a
- Control.Concurrent.Chan.Unagi.NoBlocking.Unboxed: Next :: a -> (Stream a) -> Next a
+ Control.Concurrent.Chan.Unagi.NoBlocking.Unboxed: Next :: a -> Stream a -> Next a

Files

src/Control/Concurrent/Chan/Unagi/Unboxed/Internal.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns , DeriveDataTypeable, CPP , ScopedTypeVariables #-}+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-} module Control.Concurrent.Chan.Unagi.Unboxed.Internal #ifdef NOT_x86     {-# WARNING "This library is unlikely to perform well on architectures without a fetch-and-add instruction" #-}@@ -80,6 +81,16 @@  import Prelude +-- primitive 0.7.0 got rid of Addr+#if MIN_VERSION_primitive(0,7,0)+import qualified Data.Primitive.Ptr as P+type Addr = P.Ptr Word8+nullAddr :: Addr+nullAddr = P.nullPtr+#else+import qualified Data.Primitive (Addr, nullAddr)+#endif+ -- | The write end of a channel created with 'newChan'. newtype InChan a = InChan (ChanEnd a)     deriving Typeable@@ -205,8 +216,8 @@     atomicUnicorn = Just 0xDADA instance UnagiPrim Word32 where     atomicUnicorn = Just 0xDADADADA-instance UnagiPrim P.Addr where-    atomicUnicorn = Just P.nullAddr+instance UnagiPrim Addr where+    atomicUnicorn = Just nullAddr -- These should conservatively be expected to be atomic only on 64-bit -- machines: instance UnagiPrim Int64 where
tests/Atomics.hs view
@@ -26,8 +26,14 @@     putStrLn "OK"     -- ------     putStr "    CAS... "-    testNextistentSuccessFailure-    putStrLn "OK"+    -- testNextistentSuccessFailure+    -- putStrLn "OK"+    --+    -- This failure caught me by surprise. A few runs of a million seem to trigger it:+    -- https://github.com/rrnewton/haskell-lockfree/issues/77 +    --+    -- TODO ticket: https://github.com/jberryman/unagi-chan/issues/35 +    putStrLn "SKIPPING (TODO #35)"  -- catch real stupid bugs before machine gets hot: counterSane :: IO ()
tests/Smoke.hs view
@@ -172,8 +172,8 @@   mapM_ (forkCatching False "testContention writeChan i " . mapM_ (writeChan i)) groups    ns <- replicateM nNice (C.readChan out)-  isEmpty <- C.isEmptyChan out-  if sort ns == [1..nNice] && isEmpty+  assertIsEmptyChan out "Expected out to be empty, first of all..."+  if sort ns == [1..nNice]       then let d = interleaving ns             in if d < 0.7 -- arbitrary                  then putStrLn $ "OK, BUT WARNING: low interleaving of threads: "++(show $ d)@@ -181,6 +181,14 @@       else error "What we put in isn't what we got out :("   mapM_ (`throwTo` ThreadKilled) rIds ++-- isEmptyChan was removed at some point, which is quite annoying:+assertIsEmptyChan :: C.Chan Int -> String -> IO ()+assertIsEmptyChan c err = do+  C.writeChan c 666666+  satan <- C.readChan c+  unless (satan == 666666) $+    error err   -- --------- Helpers:
tests/UnagiUnboxed.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE RankNTypes , ScopedTypeVariables , BangPatterns #-}+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, CPP #-} module UnagiUnboxed (unagiUnboxedMain) where  -- Unagi-chan-specific tests@@ -23,6 +24,22 @@  import Prelude +-- primitive 0.7.0 got rid of Addr+#if MIN_VERSION_primitive(0,7,0)+import qualified Data.Primitive.Ptr as P+type Addr = P.Ptr Word8+nullAddr :: Addr+nullAddr = P.nullPtr+plusAddr :: Addr -> Int -> Addr+plusAddr = P.advancePtr+#else+import qualified Data.Primitive (Addr, nullAddr)+-- TODO Maybe refactor & get rid of these+instance Show Addr where+    show _ = "<addr>"+#endif++ unagiUnboxedMain :: IO () unagiUnboxedMain = do     putStrLn "==================="@@ -79,14 +96,11 @@     f (minBound :: Word16)     f (minBound :: Word32)     f (minBound :: Word64)-    f (P.nullAddr `P.plusAddr` 1024 :: P.Addr)+    f (nullAddr `plusAddr` 1024 :: Addr) --- TODO Maybe refactor & get rid of these-instance Show P.Addr where-    show _ = "<addr>" -instance Num P.Addr where-+-- TODO Maybe refactor & get rid of these+instance Num Addr where instance Num Char where  @@ -152,7 +166,7 @@     when (iters >= UI.sEGMENT_LENGTH) $        error "Our sEGMENT_LENGTH is smaller than expected; please fix test"     -- just skip Addr for now TODO:-    unless (  isJust (cast _e :: Maybe P.Addr)+    unless (  isJust (cast _e :: Maybe Addr)            || isJust (cast _e :: Maybe Char)) $       forM_ [0.. iters] $ \i0 -> do         let i1 = i0+1
unagi-chan.cabal view
@@ -1,5 +1,5 @@ name:                unagi-chan-version:             0.4.1.0+version:             0.4.1.1  synopsis:            Fast concurrent queues with a Chan-like API, and more @@ -54,6 +54,7 @@ --extra-doc-files:     images/*.png --cabal-version:       >=1.18 extra-source-files: CHANGELOG.markdown+Tested-With: GHC ==7.8.4 || ==7.10.3 || ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.4  source-repository head        type:     git@@ -79,7 +80,7 @@                      , Data.Atomics.Counter.Fat    ghc-options:        -Wall -funbox-strict-fields-  build-depends:       base < 5+  build-depends:       base >= 4.7 && < 5                      , atomic-primops >= 0.8                      , primitive>=0.5.3                      , ghc-prim