{-# LANGUAGE CPP #-}
module UnliftIO.AutoUpdate
(
UpdateSettings
, defaultUpdateSettings
, updateAction
, updateFreq
, updateSpawnThreshold
, updateThreadName
, mkAutoUpdate
, mkAutoUpdateWithModify
)
where
import Control.Monad.IO.Class (liftIO)
import UnliftIO (MonadUnliftIO)
import UnliftIO.AutoUpdate.Types
#ifdef mingw32_HOST_OS
import UnliftIO.AutoUpdate.Thread
#else
import qualified UnliftIO.AutoUpdate.Event as Event
import qualified UnliftIO.AutoUpdate.Thread as Thread
import GHC.Event
mkAutoUpdate :: MonadUnliftIO m => UpdateSettings m a -> m (m a)
mkAutoUpdate :: forall (m :: * -> *) a.
MonadUnliftIO m =>
UpdateSettings m a -> m (m a)
mkAutoUpdate UpdateSettings m a
settings = do
Maybe EventManager
mmgr <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Maybe EventManager)
getSystemEventManager
case Maybe EventManager
mmgr of
Maybe EventManager
Nothing -> forall (m :: * -> *) a.
MonadUnliftIO m =>
UpdateSettings m a -> m (m a)
Thread.mkAutoUpdate UpdateSettings m a
settings
Just EventManager
_m -> forall (m :: * -> *) a.
MonadUnliftIO m =>
UpdateSettings m a -> m (m a)
Event.mkAutoUpdate UpdateSettings m a
settings
mkAutoUpdateWithModify :: MonadUnliftIO m => UpdateSettings m a -> (a -> m a) -> m (m a)
mkAutoUpdateWithModify :: forall (m :: * -> *) a.
MonadUnliftIO m =>
UpdateSettings m a -> (a -> m a) -> m (m a)
mkAutoUpdateWithModify UpdateSettings m a
settings a -> m a
f = do
Maybe EventManager
mmgr <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Maybe EventManager)
getSystemEventManager
case Maybe EventManager
mmgr of
Maybe EventManager
Nothing -> forall (m :: * -> *) a.
MonadUnliftIO m =>
UpdateSettings m a -> (a -> m a) -> m (m a)
Thread.mkAutoUpdateWithModify UpdateSettings m a
settings a -> m a
f
Just EventManager
_m -> forall (m :: * -> *) a.
MonadUnliftIO m =>
UpdateSettings m a -> (a -> m a) -> m (m a)
Event.mkAutoUpdateWithModify UpdateSettings m a
settings a -> m a
f
#endif