packages feed

quic 0.1.6 → 0.1.7

raw patch · 3 files changed

+7/−23 lines, 3 files

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.1.7++- Using System.Timeout.timeout.+ ## 0.1.6  - Fixing the race condition of `timeout`.
Network/QUIC/Connection/Timeout.hs view
@@ -1,6 +1,3 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE DeriveDataTypeable #-}- module Network.QUIC.Connection.Timeout (     timeout   , fire@@ -8,35 +5,18 @@   , delay   ) where -import Data.Typeable import Network.QUIC.Event import UnliftIO.Concurrent import qualified UnliftIO.Exception as E+import qualified System.Timeout as ST  import Network.QUIC.Connection.Types import Network.QUIC.Connector import Network.QUIC.Imports import Network.QUIC.Types -data TimeoutException = TimeoutException String deriving (Show, Typeable)--instance E.Exception TimeoutException where-  fromException = E.asyncExceptionFromException-  toException = E.asyncExceptionToException- timeout :: Microseconds -> String -> IO a -> IO (Maybe a)-timeout (Microseconds ms) dmsg action = do-    tid <- myThreadId-    timmgr <- getSystemTimerManager-#if defined(mingw32_HOST_OS)-    let killMe = void $ forkIO $ E.throwTo tid $ TimeoutException dmsg-#else-    let killMe = E.throwTo tid $ TimeoutException dmsg-#endif-        setup = registerTimeout timmgr ms killMe-        cleanup key = unregisterTimeout timmgr key-    E.handleSyncOrAsync (\(TimeoutException _) -> return Nothing) $-        E.bracket setup cleanup $ \_ -> Just <$> action+timeout (Microseconds ms) _ action = ST.timeout ms action  fire :: Connection -> Microseconds -> TimeoutCallback -> IO () fire conn (Microseconds microseconds) action = do
quic.cabal view
@@ -1,6 +1,6 @@ cabal-version:      >=1.10 name:               quic-version:            0.1.6+version:            0.1.7 license:            BSD3 license-file:       LICENSE maintainer:         kazu@iij.ad.jp