-- | Lifted "Control.Concurrent.QSem".
module Effectful.Concurrent.QSem
  ( -- * Effect
    Concurrent

    -- ** Handlers
  , runConcurrent

    -- * QSem
  , QSem
  , newQSem
  , waitQSem
  , signalQSem
  ) where

import Control.Concurrent.QSem (QSem)
import Control.Concurrent.QSem qualified as Q

import Effectful
import Effectful.Concurrent.Effect
import Effectful.Dispatch.Static

-- | Lifted 'Q.newQSem'.
newQSem :: Concurrent :> es => Int -> Eff es QSem
newQSem :: forall (es :: [Effect]). (Concurrent :> es) => Int -> Eff es QSem
newQSem = IO QSem -> Eff es QSem
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO QSem -> Eff es QSem) -> (Int -> IO QSem) -> Int -> Eff es QSem
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO QSem
Q.newQSem

-- | Lifted 'Q.waitQSem'.
waitQSem :: Concurrent :> es => QSem -> Eff es ()
waitQSem :: forall (es :: [Effect]). (Concurrent :> es) => QSem -> Eff es ()
waitQSem = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (QSem -> IO ()) -> QSem -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QSem -> IO ()
Q.waitQSem

-- | Lifted 'Q.signalQSem'.
signalQSem :: Concurrent :> es => QSem -> Eff es ()
signalQSem :: forall (es :: [Effect]). (Concurrent :> es) => QSem -> Eff es ()
signalQSem = IO () -> Eff es ()
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO () -> Eff es ()) -> (QSem -> IO ()) -> QSem -> Eff es ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QSem -> IO ()
Q.signalQSem