From 778cb14bf7fac748f962cf823442f86ac9e29780 Mon Sep 17 00:00:00 2001 From: Jens Nolte <git@queezle.net> Date: Sun, 20 Feb 2022 01:29:43 +0100 Subject: [PATCH] Align function names --- src/Quasar/Async/Fork.hs | 6 +++--- src/Quasar/Async/STMHelper.hs | 12 ++++++------ src/Quasar/Resources/Disposer.hs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Quasar/Async/Fork.hs b/src/Quasar/Async/Fork.hs index 787db63..e894435 100644 --- a/src/Quasar/Async/Fork.hs +++ b/src/Quasar/Async/Fork.hs @@ -35,17 +35,17 @@ forkSTM_ fn worker exChan = void $ forkSTM fn worker exChan forkWithUnmaskSTM :: ((forall a. IO a -> IO a) -> IO ()) -> TIOWorker -> ExceptionChannel -> STM (Awaitable ThreadId) -forkWithUnmaskSTM fn worker exChan = startShortIO (forkWithUnmaskShortIO fn exChan) worker exChan +forkWithUnmaskSTM fn worker exChan = startShortIOSTM (forkWithUnmaskShortIO fn exChan) worker exChan forkWithUnmaskSTM_ :: ((forall a. IO a -> IO a) -> IO ()) -> TIOWorker -> ExceptionChannel -> STM () forkWithUnmaskSTM_ fn worker exChan = void $ forkWithUnmaskSTM fn worker exChan forkAsyncSTM :: forall a. IO a -> TIOWorker -> ExceptionChannel -> STM (Awaitable a) -forkAsyncSTM fn worker exChan = join <$> startShortIO (forkAsyncShortIO fn exChan) worker exChan +forkAsyncSTM fn worker exChan = join <$> startShortIOSTM (forkAsyncShortIO fn exChan) worker exChan forkAsyncWithUnmaskSTM :: forall a. ((forall b. IO b -> IO b) -> IO a) -> TIOWorker -> ExceptionChannel -> STM (Awaitable a) -forkAsyncWithUnmaskSTM fn worker exChan = join <$> startShortIO (forkAsyncWithUnmaskShortIO fn exChan) worker exChan +forkAsyncWithUnmaskSTM fn worker exChan = join <$> startShortIOSTM (forkAsyncWithUnmaskShortIO fn exChan) worker exChan -- * Fork in ShortIO (with ExceptionChannel) diff --git a/src/Quasar/Async/STMHelper.hs b/src/Quasar/Async/STMHelper.hs index 143cbd1..faca6ce 100644 --- a/src/Quasar/Async/STMHelper.hs +++ b/src/Quasar/Async/STMHelper.hs @@ -2,8 +2,8 @@ module Quasar.Async.STMHelper ( -- * Helper to fork from STM TIOWorker, newTIOWorker, - startShortIO, - startShortIO_, + startShortIOSTM, + startShortIOSTM_, ) where import Control.Concurrent (forkIO) @@ -19,8 +19,8 @@ import Quasar.Utils.ShortIO newtype TIOWorker = TIOWorker (TQueue (IO ())) -startShortIO :: forall a. ShortIO a -> TIOWorker -> ExceptionChannel -> STM (Awaitable a) -startShortIO fn (TIOWorker jobQueue) exChan = do +startShortIOSTM :: forall a. ShortIO a -> TIOWorker -> ExceptionChannel -> STM (Awaitable a) +startShortIOSTM fn (TIOWorker jobQueue) exChan = do resultVar <- newAsyncVarSTM writeTQueue jobQueue $ job resultVar pure $ toAwaitable resultVar @@ -33,8 +33,8 @@ startShortIO fn (TIOWorker jobQueue) exChan = do failAsyncVar_ resultVar $ toException $ AsyncException ex Right result -> putAsyncVar_ resultVar result -startShortIO_ :: ShortIO () -> TIOWorker -> ExceptionChannel -> STM () -startShortIO_ x y z = void $ startShortIO x y z +startShortIOSTM_ :: ShortIO () -> TIOWorker -> ExceptionChannel -> STM () +startShortIOSTM_ x y z = void $ startShortIOSTM x y z newTIOWorker :: IO TIOWorker diff --git a/src/Quasar/Resources/Disposer.hs b/src/Quasar/Resources/Disposer.hs index 5817d1e..e201651 100644 --- a/src/Quasar/Resources/Disposer.hs +++ b/src/Quasar/Resources/Disposer.hs @@ -91,7 +91,7 @@ beginDisposeFnDisposer worker exChan disposeState finalizers = startDisposeFn :: DisposeFn -> STM (Awaitable ()) startDisposeFn disposeFn = do awaitableVar <- newAsyncVarSTM - startShortIO_ (runDisposeFn awaitableVar disposeFn) worker exChan + startShortIOSTM_ (runDisposeFn awaitableVar disposeFn) worker exChan pure $ join (toAwaitable awaitableVar) runDisposeFn :: AsyncVar (Awaitable ()) -> DisposeFn -> ShortIO () @@ -192,7 +192,7 @@ beginDisposeResourceManagerInternal rm = do dependenciesVar <- newAsyncVarSTM writeTVar (resourceManagerState rm) (ResourceManagerDisposing (toAwaitable dependenciesVar)) attachedDisposers <- HM.elems <$> readTVar attachedResources - startShortIO_ (void $ forkIOShortIO (disposeThread dependenciesVar attachedDisposers)) worker exChan + startShortIOSTM_ (void $ forkIOShortIO (disposeThread dependenciesVar attachedDisposers)) worker exChan pure $ DisposeDependencies rmKey (toAwaitable dependenciesVar) ResourceManagerDisposing deps -> pure $ DisposeDependencies rmKey deps ResourceManagerDisposed -> pure $ DisposeDependencies rmKey mempty -- GitLab