REF use bracket
This commit is contained in:
parent
b52b22c48d
commit
c94d83f41e
|
@ -46,12 +46,8 @@ class SafeClient c where
|
||||||
disconnectDBusClient = liftIO . disconnect . toClient
|
disconnectDBusClient = liftIO . disconnect . toClient
|
||||||
|
|
||||||
withDBusClient :: MonadUnliftIO m => (c -> m a) -> m (Maybe a)
|
withDBusClient :: MonadUnliftIO m => (c -> m a) -> m (Maybe a)
|
||||||
withDBusClient f = do
|
withDBusClient f =
|
||||||
client <- getDBusClient
|
bracket getDBusClient (mapM (liftIO . disconnect . toClient)) $ mapM f
|
||||||
forM client $ \c -> do
|
|
||||||
r <- f c
|
|
||||||
liftIO $ disconnect (toClient c)
|
|
||||||
return r
|
|
||||||
|
|
||||||
withDBusClient_ :: MonadUnliftIO m => (c -> m ()) -> m ()
|
withDBusClient_ :: MonadUnliftIO m => (c -> m ()) -> m ()
|
||||||
withDBusClient_ = void . withDBusClient
|
withDBusClient_ = void . withDBusClient
|
||||||
|
|
Loading…
Reference in New Issue